Click here to Skip to main content
15,912,507 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am using app.config file for my winforms application in order to store the connection strings as follows
XML
<connectionStrings>
    <clear />
    <add name="Survey" connectionstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\\Database\Master.mdb;Persist Security Info=True"
     providerName="System.Data.OleDb" />
    <add name="Model" connectionstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\\Database\Model.mdb;Persist Security Info=True"
      providerName="System.Data.OleDb" />
</connectionStrings>
<appsettings>
    <add key="Database" value=".\\Database\" />
    <!--<add key="Database" value=".\Survey Designer DB 8-06-2012 latest\" />-->
    <add key="LoggerLevel" value="5" />

    <add key="ClientSettingsProvider.ServiceUri" value="" />
</appsettings>

It works fine when i am working local...but when i choose a file from a share like \\172.16.2.5\

the path .\\Database\Master.mdb instead of taking file from local file system it appends \\172.16.2.5\ to
.\\Database\Master.mdb and since Database\Master.mdb is not present in the given path..it throws error ..cannot find file specified ...

I am using .\\Database\Master.mdb synatx so it remains dynamice without any hardcoded values.
Posted
Updated 29-May-13 18:24pm
v4
Comments
Prasad Khandekar 28-May-13 6:16am    
\\172.16.2.5\ won't represent the shared folder. In your case to be able to use the file from shared folder create a shared folder named Database on 172.16.2.5, copy the Master.mdb file in that folder and change path in your config file as \\172.16.2.5\Database\Master.mdb

 
Share this answer
 
Ok ..i fixed the problem .. the problem was that i was using a file open dialog box with the option restore directory as false so it happens that in win xp the working directory is changed to the file dialog folder location which user chooses so the .//database which is present in working directory is searched in network folder .. which is absent in shared folder .


this is only faced in win xp and not in win7


So in order to make it work ...i win xp we have to set restoredefault directory to true..so it brings the directory to the root application running folder..



Thanks
 
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