views:

83

answers:

1

Hi,

I have a snippet of code that should remove a text file and its' parent directory:

if (isolatedStore.FileExists(logPath + "\\" + logFileName))
    isolatedStore.DeleteFile(logPath + "\\" + logFileName;

if (isolatedStore.DirectoryExists(logPath))
    isolatedStore.DeleteDirectory(logPath);

...where logPath + "\" + logFileName might be: "Logs\log.txt"

When this executes I get an exception that says it could not create the directory, not erase it. Does anyone know why this is ?

Thanks,

Scott

+2  A: 

Are you sure the directory is empty (including any subdirectories)? The documentation here http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.deletedirectory.aspx says it must be empty (still doesnt explain why you get the strange error message). That page also has example code which shows how delete all the files first then the directory once it is empty.

barrylloyd
In the end I wasn't make sure the directories were empty - good call. The reason for the weird error message is still unknown. Thanks again!
Scott Davies