Process - Know corrupt file before opening

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I have a corrupt word file. I am able to open it with the code given below
tr
Dim pInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo(
pInfo.UseShellExecute = Tru
pInfo.FileName = "c:\corrupt.doc
Dim p As Process = System.Diagnostics.Process.Start(pInfo
Catch ex As Exceptio
MsgBox(ex.ToString
End Tr
The file opens in word application and shows that the file is corrupt. Is it possible to know about the corrupt file without passing the control to word application using Diagnostics.Process? Any help in this regard is highly appreciated.
 
Because word itself is the judge over the validity of this file, no. Unless
you had some way of reading the file in yourself and judging it as valid or
corrupt, but then chances are you would not need to open the file in word
then...


Vinay said:
Hi,
I have a corrupt word file. I am able to open it with the code given below.
try
Dim pInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo()
pInfo.UseShellExecute = True
pInfo.FileName = "c:\corrupt.doc"
Dim p As Process = System.Diagnostics.Process.Start(pInfo)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
The file opens in word application and shows that the file is corrupt. Is
it possible to know about the corrupt file without passing the control to
word application using Diagnostics.Process? Any help in this regard is
highly appreciated.
 
But I think his problem is that he ultimately needs to open the doc in MS
Word but if it is corrupt he gets errors back that are not easy to handle.
He wants to judge the file as 'valid' or 'corrupt' before he even attempts
to open it with MSWord...

Maybe if you were using MSWord 2003 you *might* (read as 'maybe, bit I am
not sure') be able to do some XML schema validation on the file outside of
MSWord before opening it.
 
Thanks a lot for your interest and suggestion. But my application might further extend to support PDF files, Bitmap files, In such a case I want to know whether the file which is being opened is corrupted or not before actually passing the control to the respective application reader. As the type of file which is supported by application might differ in future, I am thinking of using Systen.Diagnostic.Process class. Please help me in this regard.
 
The key to the entire thing here is that if YOU want to judge the file as
corrupt then YOU have to be bale to read the file in the same way that the
target application would and then make a judgment of fitness or not.

If you want to know if a word doc if valid or corrupt before you try to open
it in MS Word then you have to open the file, understand the MS Word
document structure and be bale to know if the file is corrupt or not. This
seems like an awful lot of work especially if you intend on opening many
different file types.

Perhaps you might want to consider a third party imaging toolkit like this:

http://www.leadtools.co.uk/

NOTE: A do not work for them nor am I connected to them in any way. I just
see their add allot in the back of VBPJ.


vinay said:
Thanks a lot for your interest and suggestion. But my application might
further extend to support PDF files, Bitmap files, In such a case I want to
know whether the file which is being opened is corrupted or not before
actually passing the control to the respective application reader. As the
type of file which is supported by application might differ in future, I am
thinking of using Systen.Diagnostic.Process class. Please help me in this
regard.
 
Back
Top