
Signature
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Hi Jeff
Here is the code segment where the error often occurs (but not
always).........................
Clipboard.Clear()
' Copy image to clipboard
SendMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
' Get image from clipboard and convert it to a bitmap
If My.Computer.Clipboard.ContainsImage() Then
If Not IsNothing(picCapture.Image) Then
picCapture.Image.Dispose()
picCapture.Image = Nothing
My.Application.DoEvents()
End If
If flgsubmember Then
If Not IsNothing(frmgridedit.image1.Image) Then
frmgridedit.image1.Image.Dispose()
frmgridedit.image1.Image = Nothing
My.Application.DoEvents()
End If
path = photopath & Me.Tag & submembername & ".bmp"
If My.Computer.FileSystem.FileExists(path) Then
Try
My.Computer.FileSystem.DeleteFile(path) ******** Exception here
Catch ex As IOException
MsgBox(ex.Message)
End Try
End If
Call stack...............................
mscorlib.dll!System.IO.__Error.WinIOError(int errorCode, string
maybeFullPath = "C:\\vbnet 2005 progs\\Gym
Master\\bin\\Photos\\4352Luke.bmp") + 0x47e bytes
mscorlib.dll!System.IO.File.Delete(string path) + 0x9e bytes
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.FileIO.FileSystem.DeleteFileInternal(string
file, Microsoft.VisualBasic.FileIO.FileSystem.UIOptionInternal showUI,
Microsoft.VisualBasic.FileIO.RecycleOption recycle,
Microsoft.VisualBasic.FileIO.UICancelOption onUserCancel) + 0xb2 bytes
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.MyServices.FileSystemProxy.DeleteFile(string
file) + 0x10 bytes
> Gym Master.exe!Gym_Master.frmphoto.btntakephoto_Click(Object sender =
> {Text = "Take Photo"}, System.EventArgs e =
> {System.Windows.Forms.MouseEventArgs}) Line 260 + 0x1e bytes Basic
System.Windows.Forms.dll!System.Windows.Forms.Control.OnClick(System.EventArgs
e) + 0x57 bytes
System.Windows.Forms.dll!System.Windows.Forms.Button.OnClick(System.EventArgs
e) + 0x49 bytes
System.Windows.Forms.dll!System.Windows.Forms.Button.OnMouseUp(System.Windows.Forms.MouseEventArgs
mevent = {X = 38 Y = 12 Button = Left}) + 0xc3 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref
System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button,
int clicks) + 0xf2 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref
System.Windows.Forms.Message m) + 0x544 bytes
System.Windows.Forms.dll!System.Windows.Forms.ButtonBase.WndProc(ref
System.Windows.Forms.Message m) + 0xce bytes
System.Windows.Forms.dll!System.Windows.Forms.Button.WndProc(ref
System.Windows.Forms.Message m) + 0x2b bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref
System.Windows.Forms.Message m) + 0xd bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref
System.Windows.Forms.Message m) + 0xd6 bytes
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr
hWnd, int msg = 514, System.IntPtr wparam, System.IntPtr lparam) + 0x75
bytes
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int
dwComponentID, int reason = 4, int pvLoopData = 0) + 0x2ea bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int
reason = 4, System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.Application.ModalApplicationContext}) + 0x17d bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int
reason, System.Windows.Forms.ApplicationContext context) + 0x53 bytes
System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window
owner) + 0x4ee bytes
System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog() + 0x7
bytes
Gym Master.exe!Gym_Master.frmgridedit.Button7_Click(Object sender = {Text
= "Take Photo"}, System.EventArgs e = {System.Windows.Forms.MouseEventArgs})
Line 606 + 0xa bytes Basic
System.Windows.Forms.dll!System.Windows.Forms.Control.OnClick(System.EventArgs
e) + 0x57 bytes
System.Windows.Forms.dll!System.Windows.Forms.Button.OnClick(System.EventArgs
e) + 0x49 bytes
System.Windows.Forms.dll!System.Windows.Forms.Button.OnMouseUp(System.Windows.Forms.MouseEventArgs
mevent = {X = 26 Y = 12 Button = Left}) + 0xc3 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref
System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button,
int clicks) + 0xf2 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref
System.Windows.Forms.Message m) + 0x544 bytes
System.Windows.Forms.dll!System.Windows.Forms.ButtonBase.WndProc(ref
System.Windows.Forms.Message m) + 0xce bytes
System.Windows.Forms.dll!System.Windows.Forms.Button.WndProc(ref
System.Windows.Forms.Message m) + 0x2b bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref
System.Windows.Forms.Message m) + 0xd bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref
System.Windows.Forms.Message m) + 0xd6 bytes
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr
hWnd, int msg = 514, System.IntPtr wparam, System.IntPtr lparam) + 0x75
bytes
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int
dwComponentID, int reason = 4, int pvLoopData = 0) + 0x2ea bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int
reason = 4, System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.Application.ModalApplicationContext}) + 0x17d bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int
reason, System.Windows.Forms.ApplicationContext context) + 0x53 bytes
System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window
owner) + 0x4ee bytes
System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog() + 0x7
bytes
Gym Master.exe!Gym_Master.frmmembers.Button22_Click(Object sender = {Text
= "Edit"}, System.EventArgs e = {System.Windows.Forms.MouseEventArgs}) Line
7457 + 0x9 bytes Basic
System.Windows.Forms.dll!System.Windows.Forms.Control.OnClick(System.EventArgs
e) + 0x57 bytes
System.Windows.Forms.dll!System.Windows.Forms.Button.OnClick(System.EventArgs
e) + 0x49 bytes
System.Windows.Forms.dll!System.Windows.Forms.Button.OnMouseUp(System.Windows.Forms.MouseEventArgs
mevent = {X = 18 Y = 5 Button = Left}) + 0xc3 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref
System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button,
int clicks) + 0xf2 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref
System.Windows.Forms.Message m) + 0x544 bytes
System.Windows.Forms.dll!System.Windows.Forms.ButtonBase.WndProc(ref
System.Windows.Forms.Message m) + 0xce bytes
System.Windows.Forms.dll!System.Windows.Forms.Button.WndProc(ref
System.Windows.Forms.Message m) + 0x2b bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref
System.Windows.Forms.Message m) + 0xd bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref
System.Windows.Forms.Message m) + 0xd6 bytes
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr
hWnd, int msg = 514, System.IntPtr wparam, System.IntPtr lparam) + 0x75
bytes
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int
dwComponentID, int reason = -1, int pvLoopData = 0) + 0x2ea bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int
reason = -1, System.Windows.Forms.ApplicationContext context =
{Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.WinFormsAppContext})
+ 0x17d bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int
reason, System.Windows.Forms.ApplicationContext context) + 0x53 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.ApplicationContext
context) + 0x15 bytes
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
+ 0xc0 bytes
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
+ 0xe4 bytes
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(string[]
commandLine) + 0x62 bytes
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile,
System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x32
bytes
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
+ 0x2b bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object
state) + 0x3b bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext
executionContext, System.Threading.ContextCallback callback, object state) +
0x81 bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x40 bytes
Regards
Steve
> Hi steve,
>
[quoted text clipped - 12 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
Jim Hughes - 24 Feb 2006 14:09 GMT
I found that using the Image.FromFile method left a file lock in place that
prevented manipulating the file.
What I did was load the image into a FileStream and then set the Image from
the stream.
Public Function ImageFromPath(ByVal ImagePath As String) as Image
Dim fs As System.IO.FileStream
Dim img as Image = Nothing
Try
fs = System.IO.File.OpenRead(ImagePath)
fs.Position = 0
img = System.Drawing.Image.FromStream(fs)
Catch ex As Exception
DisplayError(ex)
Finally
If Not fs Is Nothing Then
fs.Close()
End If
End Try
Return img
End Function
> Hi Jeff
>
[quoted text clipped - 228 lines]
>> This posting is provided "as is" with no warranties and confers no
>> rights.
steve - 24 Feb 2006 21:40 GMT
Jim
Thanks for the info
Worked a treat
Regards
Steve
>I found that using the Image.FromFile method left a file lock in place that
>prevented manipulating the file.
[quoted text clipped - 251 lines]
>>> This posting is provided "as is" with no warranties and confers no
>>> rights.
Hi Jeff
Jim Hughes has supplied a solution which works
Thanks for your efforts so far
Regards
Steve
> Hi steve,
>
[quoted text clipped - 12 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 28 Feb 2006 02:27 GMT
Hi steve,
I was out of office yesterday. I am glad "Jim Hughes"'s reply resolves your
problem and thank "Jim Hughes" for sharing with the community.
If you need further help, please feel free to post. Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.