locked
System.IO.PathTooLongException reference

    Question

  • Could you anyone offer a pointer to the document of System.IO.PathTooLongException for Windows Store app?

    Sorry for this dummy question, but I did do a lot online search and could not find it.


    Hong

    Wednesday, February 25, 2015 12:40 PM

All replies

  • What is the scenario you are trying to solve? What is your actual goal here?

    You couldn't find it because it doesn't exist.

    If you search for PathTooLongException in the Visual Studio Object Browser when targetting a Windows Runtime solution you'll not get any hits.

    If you look at the documentation for System.IO.PathTooLongException you'll see that Windows Store apps are not included in the Version information.

    --Rob

    Wednesday, February 25, 2015 9:57 PM
    Owner
  • Thanks for the response, Rob.

    The scenario is that a Windows Store app gets this exception, and I want to catch this exception, but have found System.IO.PathTooLongException cannot be resolved.  I am looking for the reference for this particular exception to gain more understanding including how to add the relevant reference so that I can use it in the app.

    In case you wonder how I know the app gets this exception, the app logs the exception including its type as following:

    Message: The filename or extension is too long.
    Type: System.IO.PathTooLongException 
    Stack Trace:   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
       at MyApp.MainPage.<HandleFile>d__19.MoveNext()
    


    Hong

    Thursday, February 26, 2015 12:09 AM
  • Can you share an example which produces this error?

    Tuesday, March 03, 2015 12:44 AM
    Owner
  • I have taken out the related code from the app and put it together as following:

    try
    {
        StorageFolder sf = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Temp", CreationCollisionOption.ReplaceExisting);
        await sfFile.CopyAsync(sf);
    }
    catch(Exception ex)
    {
    }
    where sfFile has the following:

    Path = "E:\\Temp\\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdddfffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddd.png"


    Hong

    Tuesday, March 03, 2015 2:33 AM