0

I want to create file and this file must create in folder App_Data in my project.

How I can do it?

 FileInfo MyFile = new FileInfo("~\\App_Data\\asd.txt");
            if (MyFile.Exists == false)
            {
                FileStream fs = MyFile.Create();
                fs.Close();
            }

I get this error

Could not find part of the path "C:\Program Files (x86)\IIS Express\~\asd.txt".

1
  • Provide a proper information.show the code.. Commented May 23, 2015 at 11:52

1 Answer 1

1

Try to use this code

FileInfo MyFile = new FileInfo(Server.MapPath("~\\App_Data\\asd.txt"));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.