creating folder

Joined
Mar 28, 2005
Messages
17
Programming Experience
Beginner
Hi everyone,

I created a folder called "Images" in my project's solution explorer. How to i access the images that are in this folder in my application?

Also, I have a "Log" folder. How to i write files into it?

Last question, when i deploy this project, will the program still know to for eg write my log files to my log folder??

Many thanks.
 
usually in winform, we may use Application.startuppath to locate our Apps. So we may access those folders with path string
VB.NET:
Application.startuppath & "\mySubFolders"

ps: my English's pool, 'cause i am a chinese. :)
 
Thanks for your reply. I am using winform.

Now, what happens when you deploy the program by creating a setup project. Let's say the program is called "Calculator" and it is going to be installed in the user's machine at c:\Program Files\Calculator.

If my subfolder called Log was the placeholder where my Calculator program writes its log files, will this subfolder be created under c:\program files\calculator?

Thanks.
 
You can have the setup program create the Log folder upon installation, but if the user deletes it for some reason, the program may crash if you don't include error checking to make sure it's there.

I think the best solution would be to create the folder via code if necessary. In your code in which you write the log files, first check to see if the folder exists and create it if it doesn't. You can do all this via the System.IO.Directory class (look at the Exists and CreateDirectory functions).
 
Yes, the best way to go about doing things is to check in your code. That also make you a good pessimistic programmer :) Try putting code like the below:

Dim di As New DirectoryInfo(Application.StartupPath & "\Calculator\Log")



If Not df.Exists Then
di.Create()


EndIf


 

Latest posts

Back
Top