
How to open a file for read that is already open by another application
you could try using the vb6 compatability set of file commands.
Imports VB = Microsoft.VisualBasic
Imports Microsoft.VisualBasic.Compatibility
then you will use
vb6.Open(nfilenumber, "filename", VB6.OpenMode.Input, VB6.OpenAccess.Read,
VB6.OpenShare.Default) (or similar)
etc. all the old file commands are now methods starting with
vb6.
try them...
robin
Quote:
> In VB6, that was easy using the OPEN statement! e.g.
> Open Filename For Binary As #hLoadFile
> or
> Open Filename For Input As #hLoadFile
> will open any file in any version of Windows regardless of the state
> of the file i.e. even if another application had opened the file and
> was still using it.
> In VB.Net I get an IOException stating "The process cannot access the
> file because the file is in use by another application" - I am opening
> the file as follows (having tried almost every other variant of file
> stream)
> Dim fIn As System.IO.FileStream = New
> System.IO.FileStream(SourceFile, System.IO.FileMode.Open,
> System.IO.FileAccess.Read, System.IO.FileShare.Read, TotalBytes * 100)
> I hoped that stating read access and shared read would work but it
> does not make any difference.
> Regards
> Ian