c# - Moving file from folder to folder -


Reading instant messages from

 : 20: S10734539 / 940   

Folder, and in the row: 20: I want to know whether the file and readings are valid or not. In this case if line: 20: There is 940, then the windows service is read and it successfully moves to the folder, but an invalid file will not have 940 on the line: 20:, the meaning of the service of the window is at the invalid file location Have to go I have written a code to do this, but it is not able to transfer the file. I get an error message 'Use File', find the snippets below my code.

  if (Directory.Exists (@ CBN_INFLOW940)) DirectoryInfo dr = new DirectoryInfo (CBN_INFLOW940); Fileinfo [] fi = dr Gatefile (); String [] files = directory. Gate Files (CBN_INFLOW940);   

int lengthchk = 0;

  if (files.Length & lt; 1) check = false; While (files.Length & gt; Lemic) {StringBuilder sb = New StringBuilder (); Logger.Info (fi [lengthchk] .name + ": read from folder"); String narrationgen = ""; bool isvalidrtgs = false; DateTimeDet = Fi [langeling]. Creationtime.dat; File stream stream = zero; Try {stream = File.Open (files [lengthcakecake], flammod.open, filesystems. Redwright, fisaiye.num); Streamerdinder sf = new streamrider (stream); }   

and

  if (line is included (": 20:")) {firstchk = 1; If (line line ('/')) {string [] fnamesplit = fi [lengthchk] .name Sample ('.'); String newfname = fnamesplit [0] + "_bk" + ".txt"; String destlocation = Invalidfilelocation940 + newfname; String sourcelocation = CBN_INFLOW940 + fi [langling]; // + "\\" file. Forward (sourcelocation, destlocation); Return; } String [] narr = line.Split ('/'); String filecode = slogan [1]; If (filecode.Trim (!! = "940") {string [] fnamesplit = fi [lengthchk] .name Sample ('.'); String newfname = fnamesplit [0] + "_bk" + ".txt"; String destlocation = Invalidfilelocation940 + newfname; String sourcelocation = CBN_INFLOW940 + "\\" + fi [langling]; File Forward (sourcelocolation, distalction); Return; }}    

Try splitting your check code with your driving code This is a better It will be designed, and you can lock the file to read, when you are trying to move it.

Think:

  if (ShouldMoveFile (filename))   

and make sure that you Close the file you are reading.

If you keep the code the same:

Add lines:

  sf.Close (); Stream.Close ();   

Before you move files.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -