473,289 Members | 1,959 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Process - Know corrupt file before opening

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
5 3117
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jole | last post by:
Hi I'm writing a program that needs to read from a file. In order for the program to be robust, it should somehow check that the file isn't corrupt, or stuffed in any way. For example, that...
6
by: BCM | last post by:
In a simple console app the following few lines open up an Acrobat file without a hitch: Process p = new Process(); p.StartInfo.FileName = @"C:\test.pdf"; p.Start(); But the same code in an...
4
by: aaj | last post by:
Hi all I have been given a corrupt access 2000 backend and asked to salvage the data.(youve gussed it, no backup) On trying to open it just kicks me out saying its not a valid database file -...
6
by: gizmo | last post by:
I have a requirement to initiate more than one instance of an application using the filenames. (the example below will start two instances of MS Word). My problem is that I need to kill each...
5
by: Vinay | last post by:
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...
13
by: George | last post by:
Hi, I am re-writing part of my application using C#. This application starts another process which execute a "legacy" program. This legacy program writes to a log file and before it ends, it...
3
by: rdemyan via AccessMonster.com | last post by:
One of my users had a corrupt front end that wouldn't open. My app is launched using a launching application (logon app). The logon app has a button for downloading a "fresh" copy of the front...
0
by: Gustavo Ortega | last post by:
Hello, When I use the follwing aspx code to get a csv file via Internet Explorer in MS Excel, after comfirm dialog box as "Open content immediately" Excel displays a corrupt worksheet name as...
1
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm running this code to open a stream as pdf file: Response.ContentType = "application/pdf"; try { mystream = someStream....; byte myfile = mystream.ReadBytes((int)someStreamLenght);...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.