Awais Rana
Awais Rana

Reputation: 7

I need help to save the file at the directory path

I have the code to save a file in a folder in directory

string timestamp = DateTime.Now.ToString("MM-dd-yyyy.HH-mm-ss");
var file = File.Create("Owe-Data.txt" + timestamp);

var com = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase + timestamp + @"\Data" + file;

MessageBox.Show(com);
if (!Directory.Exists(com))
{
      Directory.CreateDirectory(com);
}
using (var sw = new StreamWriter(com))
{
      sw.WriteLine(InputData);
}    

I Displayed COM it gives path but I can't see the Data folder or Owe-Data file at that path. Can anybody can tell why this happening? or should I save the Data folder in the current directory where this program is running?

The problem is I don't know how to reach that path?

Working on windows phone 5, visual studio 2008 .NET framwork 2.0

Upvotes: 0

Views: 487

Answers (1)

zmbq
zmbq

Reputation: 39059

Seems like you're trying to create a directory with the value of the variable com, and then write to it as if it is a file. That won't work, obviously.

Upvotes: 1

Related Questions