locked
Why StorageFolder.CreateFileAsync(String) creates file fail without any exception thrown?

    Question

  • I need to develop a windows phone store app to test file system. And I use StorageFolder.CreateFileAsync to create a file on ApplicationData.Current.LocalFolder path and write 1MB text content, and read it, modify it, and re-write it. But after about 5000 times write/read.I found that the applicaition blocked at StorageFolder.CreateFileAsync through a test method of log. However, there isn't any exception thrown. Why did the StorageFolder.CreateFileAsync  fail? And how to solve this problem? We need to write/read about 150000 times.
    Tuesday, October 21, 2014 9:22 AM

Answers

  • Hi jinchanglin,

    Have you ever tried with profiling the app while debug the app, Analyze app performance and Analyze memory usage (VB, C#, C++)

    Is it possible that CPU or memory usage reach to the limitation as you need execute the same code with nearly 150,000 times. Also you mentioned, 5000 times is ok, personally I think the code is fine, but you may need to care more about performance behavior.

    As I know if you are working with a Phone device, there is some limitation for memory usage, you cannot let your app use more memory set than that value, try to find the limitation from AppMemoryUsageLimit | appMemoryUsageLimit property

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.




    Friday, October 31, 2014 3:17 AM
    Moderator

All replies

  • Are you sure that you didn't write the files  to the same location?

    If no have a look at this:

    Access is denied when trying to CreateFileAsync in InstalledLocation StorageFolder?



    Happy Coding!

    Tuesday, October 21, 2014 2:04 PM
  • Thanks for your reply. And I write the file in the same location with the same file name by using CreationCollisionOption.ReplaceExisting. When the app runs at " StorageFile storageFile = await storageFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);", it didn't run, without any exception. I get the information by write a file log before and after this. As:

    WriteALog("start createfile");

    StorageFile storageFile = await storageFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);"WriteALog("end createfile");

    From the log, I can only see "start createfile", no "end createfile". So I don't know why storageFolder.CreateFileAsync() fail?

    Thursday, October 23, 2014 7:06 AM
  • Hi jinchanglin,

    Have you ever tried with profiling the app while debug the app, Analyze app performance and Analyze memory usage (VB, C#, C++)

    Is it possible that CPU or memory usage reach to the limitation as you need execute the same code with nearly 150,000 times. Also you mentioned, 5000 times is ok, personally I think the code is fine, but you may need to care more about performance behavior.

    As I know if you are working with a Phone device, there is some limitation for memory usage, you cannot let your app use more memory set than that value, try to find the limitation from AppMemoryUsageLimit | appMemoryUsageLimit property

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.




    Friday, October 31, 2014 3:17 AM
    Moderator
  • Hello James,

    Thanks for your comments, and sorry for late to reply to you. It is helpful with your suggestion. However, I have another question about the app performance, I use the same code, the only difference is to change the file path from local (ApplicationData.Current.LocalFolder) to sd card (KnownFolders.RemovableDevices). Then it can run 72 hours without any exception. It has good performance. Therefore, is there any difference between the two path? Thanks. Look forward to your answer.

    Tuesday, January 6, 2015 7:22 AM
  • Hi jichanglin,

    That means you can do the same action on SD card without any problem but when work with Local Folder the application blocked?

    Could you also do some test for instance when the CreateFile() method blocked, what's the size of current local folder, could it be a cache issue? However i'm not able to find many differences between them except the location via the documentation: App data

    Last but not least, Windows Phone memory/power resource is quite limited, actually I'm interested with why do you want to read/write to a single file more than 15000 times in a such high frequency.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 6, 2015 9:11 AM
    Moderator
  • Hi James,

    Thanks a lot for your reply. And I will answer your questions.

    We develop this tool to do stress test of file system. So the tool write/read/delete these files thousands of times. But not in a single file. Each time, it will create a new file, the file will also be deleted after a certain time( such as 2s).  I tried to write 1MB file each time, it failed after 2hours, but to write 1KB file each time, it can run longer, maybe 6hours fail. However, at least, the file will be deleted each time. I am very curious about why the "CreateFileAsync()" is blocked. The phenomenon happened in each test.

    I will try to monitor the memory during file system test. If any result, I will add comments.

    Thanks.

    Tuesday, January 6, 2015 9:54 AM