My app Windows forms .NET in Win XP copy files pdfs in shared network folder in a server win 2003.
Admin user in Win2003 detects some corrupt files pdfs, in that shared folder.
HOw can I check if a file is copied right in shared folder ??
the code: I use two ways to copy/move files to shared folder
-
NOte: my app generates PDFs files
-
Write Bytes to disk (the shared folder)
Public Shared Function GenerarFicheroDeBytes(ByVal datosFichero As Byte(), ByVal rutaFisicaFichero As String) As FileStream
If Not Directory.Exists(Path.GetDirectoryName(rutaFisicaFichero)) Then Directory.CreateDirectory(Path.GetDirectoryName(rutaFisicaFichero)) End If Dim fs As New FileStream(rutaFisicaFichero, FileMode.OpenOrCreate, FileAccess.Write) fs.Write(datosFichero, 0, datosFichero.Length) fs.Flush() fs.Close() Return fsEnd Function
2 Move File to shared network folder
Public Function MoverFicheroABuzonParaIndexar(ByVal rutaProcesarFicherosBuzon As String, ByVal nombreFichero As String) As String
Dim nombreFicheroPDF As String = String.Empty
Dim nombreFicheroPDFRenombrado As String = String.Empty
Dim nombreFicheroBuzon As String = String.Empty
nombreFicheroPDF = ... Path.GetFileNameWithoutExtension(...)
nombreFicheroBuzon = ObtenerRutaFicheroBuzonParaIndexar(...)
File.Move(nombreFicheroPDF, nombreFicheroBuzon)
Return nombreFicheroBuzon
End Function
To answer the question, unless you know the resulting format of the file – the only entity that can tell you if a file is corrupt or not is the application that attempts to use it. “Corruption” has no context outside of trying to use the file, it’s like saying a .doc is corrupt because my CAD application can’t read it, only Word can.
Also, File.Copy and File.Move exist as shortcut methods for moving files instead of manually streaming them yourself.