Murray Brown
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.GetFold erPath(Env ironment.S pecialFold er.MyDocum ents) & "\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?
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.GetFold
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is it really huge txt file? Why not use Settings to store strings?
ASKER
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.
ASKER
It is a small string. How would I use Registry?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
https://msdn.microsoft.com/en-us/library/aa289494(v=vs.71).aspx
ASKER
Thanks very much
ASKER