Hei all, I am new to this Server and I realy need help on specific Problem [Answered]
I am trying to move a .csv File from a Folder to another and it is actualy working but when I open the transfered File and compare it with the original one, the new File seem to be completly different. It is broken. There are new Characters in the new file which are not existing in the Origin one.
Thanks in advance
61 Replies
pelase share your code with us
looks fine
the csv looks like this: "some text one the first line"
after tranfer it looks like this: "some text one the first line ; ; ; ; ;; ; ; ;; ; "
and it is writing a number in this length: 23452356345634563 to nomething like this: 23452E+16
hm, that doesn't seem right
moving a file just copies the raw bytes i'm pretty sure
hmm I am realy comfusing and I realy need to finish this but dont know how to solve it
:/
sorry for disturbing you
i don't think the issue is with moving the file
do you think its the File ?
but it should still copy it correctly and originaly but it doesnt
i'm not really sure, you'll have to show us more code
this part is actualy only to count Datas in the csv
but I dont change the CSV
Comment out all the code, and just do the move operation
File.Move shouldn't corrupt the data
and especially not turn a number from its full representation to the exponent one
Oh, I didn't notice they said that 😅
Yeah, it's 100% not File.Move
ok ok I will comment those other things out and try the move acion only
thank you so much for your time guys !
I´ll give a feedback in a moment
Hei Hei, me again. I´ve found something weird.
I comented out this line
and replaced it with this one
and for some reason the files arent brocken.
might it be the problem ?
Directory.EnumerateFiles can't change your files content
Also just a completely pointless linq query
ok ok .... still dont get the File distroyer 😄 ok thank you anyways. Could you not close this Help section ? I would liek to give you a Feedback as soon as I found something.
I have tested something else. When I open the original file and Copy everything to my clipboard and paste it in a text file. It produces the same broken file as my Code
but I dont know where in the code it does such problem
Ask the thread owner or member with permission to close this!
that sounds weird, don't know about that
its a .csv file btw
.csv have many custom settings and grids in it ... ok anyways. Thank you guys
have a nice day 🙂
How are you viewing your CSV content?
In a text editor or as a table?
after the File.move I opend it with both. Text editor(notepad++) and table(excel)
And how are you copying the original file's data to your clipboard? From excel or notepad++
this is the corrupted file content example: H;1;270345392022;4632;;;;;;;;;;;;;;;;;;;;;;;
and this is the original H;1;70345392022;4632
from notepad
and put it in csv
That same corrupted data happen when copy to the clipboard?
yes.... but its just a test... I wanted to reproduce the move by hand
but I dont know if its the right ways
That's very weird, would you be able to share the original csv?
emmm oh sorry ... I cant 😦 becauz its an intern data
I could make an example for you
i can only imagine this happening if you copy data from like one OS to another
like between the OS and a VM
Hmmm, if you can make a reproducible example that might help 😅
But anyhow, I would honestly open the original file in a hex editor and examine the contents
hex editor ?
sorry for late response I tryed to reproduce a file with no errors
but seems that as soon as I edtited the file it also corrupted it
sooo weird haha
here is an example
When I open thi sin excel
it shows everything normal
but when I edit it it give those weird semicolon
and same when I run the File.move in code
I will respond you in 1 Hour... I have to travel with train now 😄 no Internet on my way
Your best bet is to open the original file in a hex editor and examine it
ok thank you I will try it. Sorry I was busy when I came home. Back to office. i will try it out now
I tryed the Hex thing but cant figure it out how it is possible that it adds more characters than it has after moving the file
How many bytes does the file have before and after moving?
oh thats a good question but good hint ! I will check out ass soon as I have the posibility ... I have found out a reproduce way.
open this in excel, then save it and close it. next open it with notepad and you will see that there are semicolons on top line and last line
First off, these commas are added to pad header
Second
H;1;2,
why are commas and semicolons both used to separate cells?
Third, saving in excel is different from copying the file.moving a file just updates the filesystem metadata, it doesn't copy bytes.
that's why moves can be significantly faster than copies
it's a floating point number?
2,70346E+14
You're probably right, but that won't work well with CSV
how do I even make Copys in C# ?
What do you mean?
This is true if the move is to a location on the same drive 😉
Here
Moving only updates… but how do i perform a copy
Of a file?
Yes ^^
File.Copy
File.Copy Method (System.IO)
Copies an existing file to a new file.
Ahh ok… and i can save the copy in an object ?
The copy is like any other file, you can do whatever you like with it.
Thank you ! Maybe this would solve the problem
ok thank you. I will test it again tomorrow …. Is there a way to make a file only openable with a specific app ?
No
Kk
Well
Maybe
If you run that app as a different user and set the DACL on the file to only allow that user access it's theoretically possible.
Becauz opening the csv with excel then save it and open finaly opening the file again with e.g Notepad++ breaks the file
Breaks the file how? It's possible you have notepad++ configured to change the encoding or line endings or something.
Could you maybe help with my other question ?
Normally opening a file in a text editor shouldn't change it unless you explicitly do something to change the file.
The excel does something when opening in excel
This one as an example
✅ This post has been marked as answered!