By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,465 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

Process - Know corrupt file before opening

P: n/a
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.
Jul 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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" <vk******@fcg.com> wrote in message
news:6F**********************************@microsof t.com...
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.
Jul 21 '05 #2

P: n/a
I agree that word is the best judge of what files are corrupt, but I would
imagine that it is entirely possible to drive Word via the primary interop
assemblies to discover this. (see
http://msdn.microsoft.com/library/de...ssemblies.asp).
This would be alot cleaner than creating a new process.

Nick Holmes.

"Ray Cassick (Home)" <rc************@enterprocity.com> wrote in message
news:uF**************@TK2MSFTNGP11.phx.gbl...
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" <vk******@fcg.com> wrote in message
news:6F**********************************@microsof t.com...
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.

Jul 21 '05 #3

P: n/a
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.

"Nick Holmes" <ni***@nospam.com> wrote in message
news:#H**************@TK2MSFTNGP12.phx.gbl...
I agree that word is the best judge of what files are corrupt, but I would
imagine that it is entirely possible to drive Word via the primary interop
assemblies to discover this. (see
http://msdn.microsoft.com/library/de...us/dv_wrcore/h
tml/wrrefofficeprimaryinteropassemblies.asp). This would be alot cleaner than creating a new process.

Nick Holmes.

"Ray Cassick (Home)" <rc************@enterprocity.com> wrote in message
news:uF**************@TK2MSFTNGP11.phx.gbl...
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" <vk******@fcg.com> wrote in message
news:6F**********************************@microsof t.com...
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.


Jul 21 '05 #4

P: n/a
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.
Jul 21 '05 #5

P: n/a
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" <vk******@fcg.com> wrote in message
news:F7**********************************@microsof t.com...
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.
Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.