Click here to Skip to main content
15,918,706 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Modifying XML Nodes Pin
CocaColaBoy16-Apr-08 8:52
CocaColaBoy16-Apr-08 8:52 
GeneralRe: Modifying XML Nodes Pin
Dave Kreskowiak16-Apr-08 9:23
mveDave Kreskowiak16-Apr-08 9:23 
GeneralRe: Modifying XML Nodes Pin
CocaColaBoy16-Apr-08 10:08
CocaColaBoy16-Apr-08 10:08 
GeneralRe: Modifying XML Nodes Pin
Dave Kreskowiak16-Apr-08 11:06
mveDave Kreskowiak16-Apr-08 11:06 
GeneralRe: Modifying XML Nodes Pin
CocaColaBoy16-Apr-08 11:38
CocaColaBoy16-Apr-08 11:38 
GeneralRe: Modifying XML Nodes Pin
CocaColaBoy16-Apr-08 11:55
CocaColaBoy16-Apr-08 11:55 
GeneralRe: Modifying XML Nodes Pin
Luc Pattyn16-Apr-08 12:13
sitebuilderLuc Pattyn16-Apr-08 12:13 
GeneralRe: Modifying XML Nodes Pin
Dave Kreskowiak17-Apr-08 3:00
mveDave Kreskowiak17-Apr-08 3:00 
CocaColaBoy wrote:
The purpose of using Environment.CurrentDirectory is that the location of this application will vary somewhat. Would:

Dim filePath As String = Path.Combine(Application.StartupPath, "globalConfig.xml")

...achieve the same thing?


The problem with using CurrentDirectory is that the current directory can change during the execution of your app. Application.StartupPath always points to the folder your .EXE was launched from.


CocaColaBoy wrote:
I guess my next question would be: how do I open an XML file for exclusive access? Would this allow for read/write access. I'm guessing so?


XmlDocument.Load only opens the file for shared read, share deny write, for as long as it needs to read the entire file. When the document is done loading, the file is closed.

If you wanted to retain an exlusive (basically share deny all) lock on the file, you'd have to open it using a FileStream instance. FileStream lets you specify a shared access setup when you create the filestream instance. You could then pass that stream the the XmlDocument.Load method to laod the document. Just remember to Seek the filestream back to position 0 before you try to write the XML back to the file, and, of course, close the filestream when your done.


A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007, 2008




QuestionServiceProcessInstaller account? Pin
AHeavey16-Apr-08 5:57
AHeavey16-Apr-08 5:57 
AnswerRe: ServiceProcessInstaller account? Pin
Dave Kreskowiak16-Apr-08 6:37
mveDave Kreskowiak16-Apr-08 6:37 
GeneralRe: ServiceProcessInstaller account? Pin
AHeavey16-Apr-08 6:39
AHeavey16-Apr-08 6:39 
Generalbound combobox... Pin
sabr4916-Apr-08 3:43
sabr4916-Apr-08 3:43 
GeneralRe: bound combobox... Pin
Dave Kreskowiak16-Apr-08 4:13
mveDave Kreskowiak16-Apr-08 4:13 
GeneralRe: bound combobox... Pin
sabr4916-Apr-08 4:54
sabr4916-Apr-08 4:54 
GeneralRe: bound combobox... Pin
Dave Kreskowiak16-Apr-08 8:24
mveDave Kreskowiak16-Apr-08 8:24 
Questionprinting form Pin
asha_s16-Apr-08 0:45
asha_s16-Apr-08 0:45 
GeneralRe: printing form Pin
Zaegra16-Apr-08 1:40
Zaegra16-Apr-08 1:40 
GeneralRe: printing form Pin
asha_s16-Apr-08 6:52
asha_s16-Apr-08 6:52 
GeneralRe: printing form Pin
Steven J Jowett16-Apr-08 4:08
Steven J Jowett16-Apr-08 4:08 
GeneralRe: printing form Pin
asha_s16-Apr-08 6:51
asha_s16-Apr-08 6:51 
GeneralRe: printing form Pin
Steven J Jowett16-Apr-08 12:16
Steven J Jowett16-Apr-08 12:16 
QuestionRe: printing form Pin
asha_s19-Apr-08 8:15
asha_s19-Apr-08 8:15 
GeneralRe: printing form Pin
Steven J Jowett20-Apr-08 11:12
Steven J Jowett20-Apr-08 11:12 
GeneralRe: printing form Pin
asha_s21-Apr-08 0:39
asha_s21-Apr-08 0:39 
GeneralPrinting Problem² [modified] Pin
Zaegra16-Apr-08 0:14
Zaegra16-Apr-08 0:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.