Results 1 to 4 of 4

Thread: [2008] Accessing a directory that has a . in its name

  1. #1

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    [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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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:
    1. 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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width