I'm trying to use the command below to access the Photos folder in my project:
Dim filePath As String = Application.StartupPath & "\Photos"
In the folder where my executable is, there are subfolders:
\bin\Debug
In which folder should I put my Photos folder, the Debug folder or the root folder of my project, so that the Application.StartupPath command accesses the folder correctly?
Related
I am creating a project in VB, it has a files downloader, it works fine with files like .txt or images but when I try to download an .exe, the .exe turns to corrupted file.
I'm using this code:
My.Computer.Network.DownloadFile("http://www.mediafire.com/file/w9lk3emdczlb8hi/x_y_w_h.exe", "C:\Users\" & SystemInformation.UserName & "\Desktop\x_y_w_h.exe")
Process.Start("C:\Users\" & SystemInformation.UserName & "\Desktop\x_y_w_h.exe")
Downloads the .exe from the mediafire and sets the Location path and after it it opens it with Process.Start but the .exe is corrupted
This might help you:
Dim savePath As String = "your_save_path" 'Remember to include the file_name.extension_name at the end of the save path
Dim WebClientDownload As New WebClient
WebClientDownload.DownloadFile("http://download1917.mediafire.com/breo3h1b14og/w9lk3emdczlb8hi/x_y_w_h.exe", savePath)
MsgBox("Download Complete.")
Remarks:
I had this problem in the past. You were trying to save the html web page as a .exe file as said by #DavidWilson.
To solve this, you have to find the direct download link, in this case, I right-clicked on the download button and then clicked on "copy link address". It's always a good idea to test if the link copied is functioning (some file hosting sites invoke a script to start the download, but mediafire isn't that tricky)
I would like to get path of my current running project and then go one folder up then being there go to MyFile.cfg. I tried to get that path using:
Dim currentprojectPath= System.IO.Path.GetDirectoryName(Application.ExecutablePath)
unfortunetly i get strange path:
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW
Solution tree:
Configs (folder)
ConfigX (folder)
MyFile.cfg --> file i want to read path of
UnitTestProject (folder) --> running project folder
I am currently working on a windows Application project. I have a folder named "documents" in bin/debug that contains subfolders while the subfolders contains word document files.
When I click and drag the "documents" folder, i got a complete C:\Users\Satellite\Documents\Visual Studio 2010\Projects\WindowsExplorer_VB\WindowsExplorer_VB\bin\Debug\documents. What I want is to get the location of the folder in bin/debug so that the application can read from the directory when installed on a different machine..
Any help...
Try this:
Dim docPath As String = Path.Combine(My.Application.Info.DirectoryPath, "documents")
I have added some files that I need to be downloaded to the Application start up path. So I set Build Action as content now the files have been copied some where
C:\Documents and Settings\TestUser.ANNAM\Local Settings\Apps\2.0\Data\HVDRBMY5.8AA\858AT9VM.TNP\test..tion_2d7cfc137d9c2c74_0001.0013_432bd4561850d290\Data
How can access file from the application. My problem since it is a dynamic path will it be same folder count so that we can use like ....\Data\ Some think like this
You can use My.Application.Info.DirectoryPath this will return the directory where the application is stored.
I have added some files that I need to be downloaded to the Application start up path. So I set Build Action as content now the files have been copied some where
C:\Documents and Settings\TestUser.ANNAM\Local Settings\Apps\2.0\Data\HVDRBMY5.8AA\858AT9VM.TNP\test..tion_2d7cfc137d9c2c74_0001.0013_432bd4561850d290\Data
How can access file from the application. My problem since it is a dynamic path will it be same folder count so that we can use like ..\..\Data\ Some think like this
Application.UserAppDataPath gets the path for the application data of a user.
Application.StartupPath gives you the path for the executable file that started the application, not including the executable name.
Starting with one of these, you should be able to use System.IO to manipulate the paths until you get the folder where your data files are.