Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net Write file to local machine

Hi

I have to write a text file to a location on a user's local machine. The machine is
on a company network and I previously wrote the file to:
Dim oLocation as String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\Settings\Settings.txt"
but this proved problematic as when my code looked at the same location on certain machines it found a different folder.
This may well have been caused by the IT department changing things.

What I need is a location that won't change and will always allow a file to be written to it.
Should I write to the C: drive? Do all computers have a C: drive?
What is the best place to write to?
ASKER CERTIFIED SOLUTION
Avatar of Karrtik Iyer
Karrtik Iyer
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thanks. What code would I use to get this folder. Is there something similar to System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
Avatar of Ark
Is it really huge txt file? Why not use Settings to store strings?
The Settings get wiped every so often. Some sort of Microsoft bug I think. I have installed my Excel Add-ins in hundreds of machines over the past few years and found that this happens. Hence my need for a more rigid alternative
There is no 100% proof - the user can delete your *.txt file as well. For small strings you can use registry as alternative.
It is a small string. How would I use Registry?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To read and write registry entries .Net provides infrastructure/classes. Please refer the below link from msdn to understand how it works.
https://msdn.microsoft.com/en-us/library/aa289494(v=vs.71).aspx
Thanks very much