Quantcast
Channel: Compressing files
Viewing all articles
Browse latest Browse all 16

Compressing files

$
0
0

Hi

 

Firstly apologies if this is in the wrong place.

 

I have almost finished my app, i have written in vb.net + vs2005 + Vista. I have found some code to compress files using shell32, this works perfectly well using Vista, but as soon as i try to compress on XP SP2 it crashes just before the copyhere statement. I have referenced the shell32 dll and it copies the dll locally and also deploys the file, maybe it is a compatibility issue.

 

Here is the code, as i said it is from the net.

 

'create zip folder

Dim Encoder AsNew System.Text.ASCIIEncoding

Dim Header AsString = "PK"& Chr(5) & Chr(6)

Header = Header.PadRight(22, Chr(0))

My.Computer.FileSystem.WriteAllBytes(Filename, Encoder.GetBytes(Header), True)

 

Dim Shl AsNew Shell32.Shell

'copy file to zip folder

Dim Input AsString = MainFolderPath & "\Data.mdb"

Shl.NameSpace(Filename).CopyHere(Input, 256)

 

The error reports

 

************** Exception Text **************
System.InvalidCastException: Unable to cast COM object of type 'Shell32.ShellClass' to interface type 'Shell32.IShellDispatch5'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{866738B9-6CF2-4DE8-8767-F794EBE74F4E}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
   at Shell32.ShellClass.NameSpace(Object vDir)
   at Pilots_Pal.clsFileOps.CompressFile() in C:\PilotsPal\Visual Studio 2005 Projects\PC Pilots Pal\Pilots Pal\Pilots Pal\clsFileOps.vb:line 137
   at Pilots_Pal.RestoreDB.cmdBackup_Click(Object sender, EventArgs e) in C:\PilotsPal\Visual Studio 2005 Projects\PC Pilots Pal\Pilots Pal\Pilots Pal\RestoreDB.vb:line 203
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

I thought i was close to deployment, but this has stumped me.

 

Any  help would be great

 

Kind regards

 

Steve


Viewing all articles
Browse latest Browse all 16

Latest Images

Trending Articles





Latest Images