I created a C# application in Visual C#. The application uses StreamWriter to write text files. The path of the text file is given application directory.
StreamWriter sw = new StreamWriter(Application.StartupPath + @"\myTExtFile.txt", true);
sw.Write((Keys)num);
sw.Close();
Now when I run the compiled .exe application in Windows, it runs successfully creating the text file. But when I try to run it on Mac with Mono Framework, it doesn't create the text, although it runs successfully without any error.
The application must be creating the text file, but I am unable to locate it.
Try debugging and looking at the Application.StartupPath property
or:
var fullPath = Path.Combine (Application.StartupPath, "myTExtFile.txt");
Console.WriteLine (fullPath);
BTW: Use Path.Combine vs. string concatenation as it is xplat-based and you do not have to deal with path separators.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.