Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,23 @@ public static void Main()
{
isoStore.CreateDirectory("TopLevelDirectory");
isoStore.CreateDirectory("TopLevelDirectory/SecondLevel");
isoStore.CreateDirectory("AnotherTopLevelDirectory/InsideDirectory");
Console.WriteLine("Created directories.");
var isofilename = "AnotherTopLevelDirectory/NewFile.txt";
try
{
isoStore.CreateFile(isofilename);
}
catch (IsolatedStorageException iex)
{
Console.WriteLine(iex.ToString());
}

var path = Path.GetDirectoryName(isofilename);
isoStore.CreateDirectory(path);//Creating "AnotherTopLevelDirectory";
isoStore.CreateFile(isofilename);//Creating "AnotherTopLevelDirectory/NewFile.txt";

isoStore.CreateFile("AnotherTopLevelDirectory/InsideDirectory");
Console.WriteLine("Created directories.");

Comment on lines +28 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change intentional? It removes the "InsideDirectory" and then you try to create a file as a directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not actually deleted but moved to 2nd last line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @OzBob Sorry about that, I was on vacation. I just got back. What I mean is that the directory "InsideDirectory" doesn't seem to be created anymore? Unless I'm missing something, which is possible.

I just created a test project and ran the original code. It worked as expected:

dotnet run

Created directories.
Created a new file in the root.
Created a new file in the InsideDirectory.

I then ran the code from this PR and it failed:

dotnet run

System.IO.IsolatedStorage.IsolatedStorageException: Operation not permitted on IsolatedStorageFileStream.
 ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\thrak\AppData\Local\IsolatedStorage\5uysulys.woc\5ou1xfgf.iws\Url.2txcxmkov3cbmd5tmqeaz0ccetpw5zem\Url.2txcxmkov3cbmd5tmqeaz0ccetpw5zem\Files\AnotherTopLevelDirectory\NewFile.txt'.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.IsolatedStorage.IsolatedStorageFileStream.InitializeFileStream(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
   --- End of inner exception stack trace ---
   at System.IO.IsolatedStorage.IsolatedStorageFileStream.InitializeFileStream(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
   at System.IO.IsolatedStorage.IsolatedStorageFile.CreateFile(String path)
   at tempcode.Program.Main() in C:\temp\tempcode\Program.cs:line 18
Created directories.
Created a new file in the root.
Unhandled exception. System.IO.IsolatedStorage.IsolatedStorageException: Operation not permitted on IsolatedStorageFileStream.
 ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\thrak\AppData\Local\IsolatedStorage\5uysulys.woc\5ou1xfgf.iws\Url.2txcxmkov3cbmd5tmqeaz0ccetpw5zem\Url.2txcxmkov3cbmd5tmqeaz0ccetpw5zem\Files\AnotherTopLevelDirectory\InsideDirectory\HereIAm.txt'.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.IsolatedStorage.IsolatedStorageFileStream.InitializeFileStream(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
   --- End of inner exception stack trace ---
   at System.IO.IsolatedStorage.IsolatedStorageFileStream.InitializeFileStream(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
   at System.IO.IsolatedStorage.IsolatedStorageFile.CreateFile(String path)
   at tempcode.Program.Main() in C:\temp\tempcode\Program.cs:line 35

isoStore.CreateFile("InTheRoot.txt");
Console.WriteLine("Created a new file in the root.");

Expand All @@ -22,4 +36,4 @@ public static void Main()
}
}
}
//</snippet1>
//</snippet1>