In my code
using (var package = Package.Open(filePathAndName, FileMode.Create))
{
errorCode = WritePackagedPartGroups(package, partGroups);
if (errorCode == PackagedIOErrorCode.NoError &&
signCertificate != null)
{
errorCode = SignPackage(package, signCertificate);
}
}
i try to create a Zip-File while uising Package.Open from System.IO.Packaging but i got an exception while trying to create it. The Exception is a System.IO.IOException: The directory or file cannot be created
The full Stacktrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at MS.Internal.IO.Zip.ZipArchive.OpenOnFile(String path, FileMode mode, FileAccess access, FileShare share, Boolean streaming)
at System.IO.Packaging.ZipPackage..ctor(String path, FileMode mode, FileAccess access, FileShare share, Boolean streaming)
at System.IO.Packaging.Package.Open(String path, FileMode packageMode, FileAccess packageAccess, FileShare packageShare, Boolean streaming)
at System.IO.Packaging.Package.Open(String path, FileMode packageMode)
at ...Data.PackagedDataIO.PackagedDataWriter.Write(String filePathAndName, IEnumerable`1 partGroups, X509Certificate signCertificate) in ...Data\PackagedDataIO\PackagedDataWriter.cs:line 33
The problem only occures in the root-path for any device/hard drive/removable device. When creating a new directory in the root and try to save the file in the new directory the creation is succesfull. So for example the path "C:\testFile.zip" is not working but "C:\testDirectory\testFile.zip" is working. I tried replacing the backslashes with "/" and i also checked for the filesystem. There´s no difference between fat32 or ntsc. I checked the devices for accessrights and read-only problems. Everything seems to be fine.
Can anyone see, what´s wrong. Are there known issues with root-paths and io.packaging