473,396 Members | 2,087 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,396 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 3127
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);...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.