Need help with System.IO (C#) (C++, if you replace the -> with .)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brclancy111
    New Member
    • Oct 2007
    • 3

    Need help with System.IO (C#) (C++, if you replace the -> with .)

    Hello. I've been programming for 1 year now, and never saw this coming...
    When I try to use
    Code:
    File.Exists("Data/Settings.dat")
    it does absolutely nothing.

    I am trying to build a system that automatically makes a file, if it doesn't exist, after it has been encoded.

    Code:
    string Settings = "";
                string[] NewSettings = { "[BGM 10]", "[SFX 10]", "[ViewDistance 10]", "[Textures 10]", "[Lighting 5]", "[Shadows 5]", "[Gamma 0]", "[Sharpness 0]" };
                string Encoded = EncodeSettings(NewSettings);
                MessageBox.Show(Encoded);
                if (File.Exists("Data/Settings.dat")) { Settings = System.IO.File.ReadAllText("Data/Settings.dat"); }
                else
                {
                    File.WriteAllText("Data/Settings.dat", Encoded);
                }
    On every System.IO I use on my program will not write / Detect if the file exists.

    No Debug window popped up.

    P.S. this program happens to be a 1000+ Liner, so I cannot place the full thing here. If you're willing to try and read the 1000+, here it is
  • brclancy111
    New Member
    • Oct 2007
    • 3

    #2
    ah..found the problem...the files were going into the drive folder instead of the wanted folder
    Last edited by sicarie; Feb 27 '08, 02:08 PM. Reason: Moved to .NET Forum, belatedly....

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      I was going to suggest verifying that the files really do exist, as File.Exists() is usually pretty solid.

      Comment

      • brclancy111
        New Member
        • Oct 2007
        • 3

        #4
        I was missing
        Code:
        System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
        For the current folder.

        Comment

        Working...