C# SD卡WP SL 8.1上的文件名存在问题
我在SD卡上创建了一个名为“Products.txt”的文件。当我第一次打开它时,它的名称是“产品[1].txt”,第二次是“产品[2].txt”,第三次是“产品[1].txt”,依此类推。我不明白为什么,因为我没有另一个同名的文件。我最大的问题是,我想在里面写东西,每次我写东西的时候,都会产生一个新的问题。有人知道为什么名字会改变,以及如何解决这个问题吗?谢谢 首次写入代码:C# SD卡WP SL 8.1上的文件名存在问题,c#,windows-phone-8.1,windows-phone-sl-8.1,windows-phone-silverlight,C#,Windows Phone 8.1,Windows Phone Sl 8.1,Windows Phone Silverlight,我在SD卡上创建了一个名为“Products.txt”的文件。当我第一次打开它时,它的名称是“产品[1].txt”,第二次是“产品[2].txt”,第三次是“产品[1].txt”,依此类推。我不明白为什么,因为我没有另一个同名的文件。我最大的问题是,我想在里面写东西,每次我写东西的时候,都会产生一个新的问题。有人知道为什么名字会改变,以及如何解决这个问题吗?谢谢 首次写入代码: StorageFolder myFolder = await KnownFolders.PicturesLib
StorageFolder myFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync("MyFolder", CreationCollisionOption.ReplaceExisting);
StorageFile myFile = await myFolder.CreateFileAsync("MyFile.txt", CreationCollisionOption.ReplaceExisting);
Stream f = await myFile.OpenStreamForWriteAsync();
using (StreamWriter sw = new StreamWriter(f))
{
sw.WriteLine("First");
}
其他文字代码:
StorageFolder sf = KnownFolders.PicturesLibrary.GetFolderAsync("MyFolder");
StorageFile f = sf.GetFileAsync("MyFile.txt");
using(Stream s = await f.OpenForWriteAsync())
{
using(StreamWriter sw = new StreamWriter(s, true))
{
sw.WriteLine("Others");
}
}
只需更改流f=wait myFile.OpenStreamForWriteAsync()通过
使用(Stream f=await myFile.OpenStreamForWriteAsync())
进行编码,问题得到解决如果没有任何代码,很难得到帮助。显示创建文件的代码和读取文件的代码。@venerik我编辑了它。你现在能帮我吗?谢谢@Mihai告诉我什么是最好的
:问这个问题与你的原创无关question@MangeshGhotage如果你知道,告诉我一个关于文件名问题的好答案,因为这是我真正的问题。就我所知,我把它删掉了