Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

Basically it's a IU where user can open a text file through notepad.
The user is then suppose to:
*Change some values in the text file
*save the document though notepad
*get back to the UI.

The problem is that the document can't be saved because "file is open in other program and can't be saved." (translated error massage)

Is there any way of getting around this problem.
I have snipped out the code below.

VB
Dim ProcessProperties As New ProcessStartInfo
Dim myProcess As Process
reader.close()
ProcessProperties.FileName = "notepad.exe"
ProcessProperties.Arguments = lblCurrentFilePath
ProcessProperties.WindowStyle = ProcessWindowStyle.Normal
myProcess = Process.Start(ProcessProperties)
myProcess.WaitForExit()
myProcess.Kill()
OpenFileDialog1_FileOk(bFileEditM, AcceptButton)


Best regards

What I have tried:

not much, only the code above. Don't know any solution.
Posted
Updated 28-Sep-18 2:27am
v2
Comments
Leo Chapiro 28-Sep-18 8:28am    
Try to open a file in shared mode: File.Open Method

1 solution

If Notepad can't save the file, it's because either you app has the file open, another app has the file open for shared read but not write, or the user doesn't have permissions to write a file in the folder/location that it is in, such as the root of C: or under Program Files somewhere, or some other location secured by permissions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900