|
-
Oct 8th, 2009, 08:14 PM
#1
Thread Starter
Junior Member
Creating automatic log file folder
Hi all,
Currently i developing a system which require me to create a log file.
My code is working but I need to enhance it make the log file folder create automatically bcoz right now i have to create the folder manually in the debug folder.
Here is my code:
FileOpen(1, (Application.StartupPath & "\Log\" & lotno & ".txt"), OpenMode.Append)
PrintLine(1, "Start Time : ", Now())
PrintLine(1, "Lot Number : ", lotno)
PrintLine(1, "Test Software : ", title)
PrintLine(1, "Staff ID : ", operID)
PrintLine(1,
PrintLine(1, "")
FileClose(1)
Hope someone can help me
-
Oct 8th, 2009, 08:26 PM
#2
Re: Creating automatic log file folder
Is this vb.net? I've never heard of FileOpen and PrintLine commands. Also what do you mean by developing a system?
Either way I'm sure google would give you the answer in seconds if you would just ask it a question...
-
Oct 8th, 2009, 08:28 PM
#3
Re: Creating automatic log file folder
Get rid of that VB6-style I/O altogether. In VB.NET you use the members of the System.IO namespace or the My.Computer.FileSystem object to read and write files. For instance, to write multiple lines to a text file you should either open a StreamWriter and call WriteLine on it multiple times or, more simply call File.WriteAllLines or .AppendAllLines. Those last two options will also create the folder if required, while I'm not sure about the StreamWriter. Probably not but you can test that. If not the Directory.CreateDirectory will do it.
-
Oct 8th, 2009, 08:41 PM
#4
Hyperactive Member
Re: Creating automatic log file folder
vb Code:
Dim szTmpPath As String = System.IO.Path.Combine(Application.StartupPath, "Log")
Dim dirInfo As New System.IO.DirectoryInfo(szTmpPath)
' if folder not exist, create
If Not dirInfo.Exists Then dirInfo.Create()
-
Oct 8th, 2009, 09:22 PM
#5
Thread Starter
Junior Member
Re: Creating automatic log file folder
Hi guys,
Thanks for ur help..
Actually this system is migration from vb6 to vb.net..
I just enhanced it from the previous source cord..
-
Oct 8th, 2009, 09:50 PM
#6
Re: Creating automatic log file folder
Then it's time to enhance it further.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|