2
Answers

Testing if a file is complete

Photo of Frank Galavan

Frank Galavan

14y
6.8k
1

I am kinda new to C#, so please bear with me.
What is the easiest way to test if a file is complete?
Let me explain. A company outside is sending us text files throughout the day. They can range is size from several thousand bytes to almost  250 megs. My program runs from a Scheduled Task throughout the day. The short files are usually no problem, but the big ones can be and often are still in the process of being transmitted into the directory from outside.
The way I have been testing this is to try and rename the file. If I get an exception, I know its still writing. Is there an easier way to test that a file is complete?
Thanks
Frank

Answers (2)

0
Photo of Dipika
NA 1.2k 14.6k 7y
my task is to upload file with updated version 6th step of following url
 
https://developer.autodesk.com/en/docs/data/v2/tutorials/upload-file/ 
0
Photo of Mitesh Gadhiya
NA 305 11.1k 7y
  1. var url = "API URL";  
  2. var jsonData = "[{...json data...}]";  
  3.   
  4. using (var client = new WebClient())  
  5. {  
  6.     client.Headers.Add("content-type""application/json");  
  7.     var response = client.UploadString(url, jsonData);  
 Try this
0
Photo of Dipika
NA 1.2k 14.6k 7y
I have to integrate this 
https://developer.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-versions-POST/ 
0
Photo of Dipika
NA 1.2k 14.6k 7y
What should i pass in query string or in request.AddHeader
0
Photo of Mitesh Gadhiya
NA 305 11.1k 7y
Please have a look at below thread it might be helpful to you:
 
https://stackoverflow.com/questions/7929013/making-a-curl-call-in-c-sharp