hello good morning.
can someone sugest. i am developing the code in my laptop i am downloading the data from website saving in my pc folder somewhere. but how to do it dynamically by which when i install that code in any others system. it should run without exception. and how to save and read the file.
By the usage of relative path & datetime properties, you can make the file be saved dynamically by the combination of these methods:
→ currentDirectory = Environment.CurrentDirectory
→ relativePath = "Data\Output"
→ fileName = "yourFileName_"+Now.ToString("dd_MM_yyyy")+".yourFileExtension"
→ savingLocation = Path.Combine(currentDirectory, relativePath, fileName)
Hope this helps,
Best Regards.
@Shubham_Kinge ,
While Saving you can provide
Path.Combine(Environment.CurrentDirectory,"YourFilepathInsidetheDirectory")
Here “YourFilepathInsidetheDirectory” will be something like “data\Input\sample.xlsx”
Regards,
Use any generic location like C:\Working folder
which can be created in any system…
Or use relative path "Data\Input"
Or use environment.username
which gives the current user name and can use user related folders as well Path.Combine("C:\users\,Environment.Username,"\documents")
Or
Can use project folder by using environment.currentdirectory
Hope this helps
Cheers
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.