|
-
Jan 15th, 2009, 09:34 PM
#1
[2008] Accessing a directory that has a . in its name
For some annoying reason you can actually create directories with full stops in them... and Microsoft just so happened to of set the default path for one of the Exchange server log files to go into a folder named Server.log. Yes it is definitley a folder not a file, there are .log files within the folder too though.
So, I'm trying to parse some of these tab delimited log files but I cant actually get at them because whenever I try and access the Server.log directory my code just dies. I mean, it doesnt throw an exception, it just stops executing. The form is still responsive etc but the parsing routing doesnt do anything and if i step into the code i see that it gets to the line that tries to access the server.log directory and then it just jumps straight out of debug mode.
If i move one of the log files out of the Server.log directory then my code works fine so what can I do?
I tried using IO.Path.Combine but that doesnt work either (and for once I'm not saying "it doesnt work" and giving you no error details because im useless, its just because there are no error details!)
Any suggestions?
Chris
-
Jan 15th, 2009, 09:50 PM
#2
Re: [2008] Accessing a directory that has a . in its name
Can you show us this code because, as far as I'm aware, having dots in a folder name should make no difference whatsoever.
-
Jan 15th, 2009, 10:00 PM
#3
Re: [2008] Accessing a directory that has a . in its name
As proof, try running this code:
Code:
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Directory.CreateDirectory("C:\Test.log")
File.WriteAllText("C:\Test.log\Test.txt", "The file is in a folder with a dot in the name.")
Directory.CreateDirectory("C:\Test.log\.Logs")
File.WriteAllText("C:\Test.log\.Logs\Test.txt", "The file is in a folder with a dot at the start of the name.")
MessageBox.Show(File.ReadAllText("C:\Test.log\Test.txt"))
MessageBox.Show(File.ReadAllText("C:\Test.log\.Logs\Test.txt"))
Directory.Delete("C:\Test.log", True)
End Sub
End Class
It worked exactly as expected for me. If you look in Windows Explorer before dismissing the second message you'll see the folders.
-
Jan 16th, 2009, 05:05 AM
#4
Re: [2008] Accessing a directory that has a . in its name
Well this is odd... running the same code today on a different PC is working and I havent modified the code at all.
This is what I had:
vb Code:
Dim parser As FileIO.TextFieldParser = My.Computer.FileSystem.OpenTextFieldParser("C:\test\test.log\testing.log", vbTab)
I think Visual Studio was just screwed on my other PC yesterday afternoon as I noticed that exceptions didn't seem to be getting thrown properly. I mean the ones that just popup in VS when you dont have a Try Catch block in place. It was as if I was using something like "On Error Resume Next" because whenever an exception should of been thrown, the app just carried on and ignored it...
After I noticed that they didnt seem to be getting thrown I tried something that I knew would cause an exception, like reading in a file from a location that didnt exist in the form load event... and sure enough, the form just loaded fine with no warnings or exceptions being thrown. I restarted VS and tried creating new projects etc but all did the same. Hopefully it will be ok tonight
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
|