469,921 Members | 2,183 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,921 developers. It's quick & easy.

Problem with file path "\" storage and retrival differences

I use FolderBrowserDlg for user to select a folder path then store it in the
sql table. I then retrieve it to concatenate in a sqlcommand text to retrive
files from that directory but it won't work because the database has it as
"\\Support\VMS\VMSDB" while the C# code expects to see
@"\\Support\\VMS\\VMSDB" . Is there a way to fix this?

Thanks,
alpha
Nov 17 '05 #1
10 1983
@"\\Support\VMS\VMSDB";

or

"\\\\Support\\VMS\\VMSDB";

--

Derek Davis
dd******@gmail.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
I use FolderBrowserDlg for user to select a folder path then store it in
the
sql table. I then retrieve it to concatenate in a sqlcommand text to
retrive
files from that directory but it won't work because the database has it as
"\\Support\VMS\VMSDB" while the C# code expects to see
@"\\Support\\VMS\\VMSDB" . Is there a way to fix this?

Thanks,
alpha

Nov 17 '05 #2
Thank you for the reyply. I know the proper format that C# expects. My
question is: Is there a function call or somehting that can covert the path
data I retrieve from the SQL database (stored there by FolderBrowserDlg) to
the proper format.

Thanks.

"carion1" wrote:
@"\\Support\VMS\VMSDB";

or

"\\\\Support\\VMS\\VMSDB";

--

Derek Davis
dd******@gmail.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
I use FolderBrowserDlg for user to select a folder path then store it in
the
sql table. I then retrieve it to concatenate in a sqlcommand text to
retrive
files from that directory but it won't work because the database has it as
"\\Support\VMS\VMSDB" while the C# code expects to see
@"\\Support\\VMS\\VMSDB" . Is there a way to fix this?

Thanks,
alpha


Nov 17 '05 #3

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Thank you for the reyply. I know the proper format that C# expects. My
question is: Is there a function call or somehting that can covert the
path
data I retrieve from the SQL database (stored there by FolderBrowserDlg)
to
the proper format.

Thanks.

"carion1" wrote:
@"\\Support\VMS\VMSDB";

or

"\\\\Support\\VMS\\VMSDB";

--


Yeah, store it in a string var and use String.Replace :)

string path = GetPathFromDb(); // Returns "\\Support\VMS\VMSDB"
path = path.Replace(@"\", @"\\");

And there ya have it :)

Mythran

Nov 17 '05 #4
Thank you. That'll work for me.

"Mythran" wrote:

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Thank you for the reyply. I know the proper format that C# expects. My
question is: Is there a function call or somehting that can covert the
path
data I retrieve from the SQL database (stored there by FolderBrowserDlg)
to
the proper format.

Thanks.

"carion1" wrote:
@"\\Support\VMS\VMSDB";

or

"\\\\Support\\VMS\\VMSDB";

--


Yeah, store it in a string var and use String.Replace :)

string path = GetPathFromDb(); // Returns "\\Support\VMS\VMSDB"
path = path.Replace(@"\", @"\\");

And there ya have it :)

Mythran

Nov 17 '05 #5
Can you tell me what's that "@" for ? I see that in several string function
but not sure what it's for. Thanks.

"Mythran" wrote:

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Thank you for the reyply. I know the proper format that C# expects. My
question is: Is there a function call or somehting that can covert the
path
data I retrieve from the SQL database (stored there by FolderBrowserDlg)
to
the proper format.

Thanks.

"carion1" wrote:
@"\\Support\VMS\VMSDB";

or

"\\\\Support\\VMS\\VMSDB";

--


Yeah, store it in a string var and use String.Replace :)

string path = GetPathFromDb(); // Returns "\\Support\VMS\VMSDB"
path = path.Replace(@"\", @"\\");

And there ya have it :)

Mythran

Nov 17 '05 #6
String literal. It allows you to use back slashes or whatever you want
without escaping it.

--
Derek Davis
dd******@gmail.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
Can you tell me what's that "@" for ? I see that in several string
function
but not sure what it's for. Thanks.

"Mythran" wrote:

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
> Thank you for the reyply. I know the proper format that C# expects.
> My
> question is: Is there a function call or somehting that can covert the
> path
> data I retrieve from the SQL database (stored there by
> FolderBrowserDlg)
> to
> the proper format.
>
> Thanks.
>
> "carion1" wrote:
>
>> @"\\Support\VMS\VMSDB";
>>
>> or
>>
>> "\\\\Support\\VMS\\VMSDB";
>>
>> --


Yeah, store it in a string var and use String.Replace :)

string path = GetPathFromDb(); // Returns "\\Support\VMS\VMSDB"
path = path.Replace(@"\", @"\\");

And there ya have it :)

Mythran

Nov 17 '05 #7
Thank you .

"carion1" wrote:
String literal. It allows you to use back slashes or whatever you want
without escaping it.

--
Derek Davis
dd******@gmail.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
Can you tell me what's that "@" for ? I see that in several string
function
but not sure what it's for. Thanks.

"Mythran" wrote:

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
> Thank you for the reyply. I know the proper format that C# expects.
> My
> question is: Is there a function call or somehting that can covert the
> path
> data I retrieve from the SQL database (stored there by
> FolderBrowserDlg)
> to
> the proper format.
>
> Thanks.
>
> "carion1" wrote:
>
>> @"\\Support\VMS\VMSDB";
>>
>> or
>>
>> "\\\\Support\\VMS\\VMSDB";
>>
>> --

Yeah, store it in a string var and use String.Replace :)

string path = GetPathFromDb(); // Returns "\\Support\VMS\VMSDB"
path = path.Replace(@"\", @"\\");

And there ya have it :)

Mythran


Nov 17 '05 #8
Well, not quite. It still doesn't work. I debug the steps and the string
var strATSPath = @"\\\\support\\VMS\\VMSDB" but the Directory.Getfiles
responded with directory not found. Does it just not like the Server name
instead of C drive? or is it the 4 back slashes"\\\\"?

Thanks.
try
{
scGetPath = new SqlCommand("select LogFilePath from Admin", conDB);
strATSPath = scGetPath.ExecuteScalar().ToString();
strATSPath = strATSPath.Replace(@"\", @"\\");
}
catch(Exception ex)
{
MessageBox.Show("Error getting the ATS file path : " + ex.ToString()+
"Please contact your support person.", "VMS - ATS file path error",
MessageBoxButtons.OK, MessageBoxIcon.Error);

}

//Get the latest ATS Access DB file name
try
{//@"C:\\VMS\\VMSDB"
string[] ATSFiles = Directory.GetFiles(strATSPath, "Ats*Db.mdb");
Array.Sort(ATSFiles);
NewATS= ATSFiles[ATSFiles.Length - 1];
}

"Mythran" wrote:

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Thank you for the reyply. I know the proper format that C# expects. My
question is: Is there a function call or somehting that can covert the
path
data I retrieve from the SQL database (stored there by FolderBrowserDlg)
to
the proper format.

Thanks.

"carion1" wrote:
@"\\Support\VMS\VMSDB";

or

"\\\\Support\\VMS\\VMSDB";

--


Yeah, store it in a string var and use String.Replace :)

string path = GetPathFromDb(); // Returns "\\Support\VMS\VMSDB"
path = path.Replace(@"\", @"\\");

And there ya have it :)

Mythran

Nov 17 '05 #9

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
Well, not quite. It still doesn't work. I debug the steps and the string
var strATSPath = @"\\\\support\\VMS\\VMSDB" but the Directory.Getfiles
responded with directory not found. Does it just not like the Server name
instead of C drive? or is it the 4 back slashes"\\\\"?

Thanks.


Well, since you are using the @ symbol, don't escape the string..IE:

string strATSPath = @"\\support\VMS\VMSDB";

HTH :)

Mythran

Nov 17 '05 #10
Ok, I finally figured out the problem. I forgot to share the folder. Dah...
Thanks for your help.

FYI, it still needs the double slashes format for the directory.getfiles.
However, before I concatenate into the SQL query string I string.replace it
back to the single slash for it to work.

Thanks, Alpha

"Mythran" wrote:

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
Well, not quite. It still doesn't work. I debug the steps and the string
var strATSPath = @"\\\\support\\VMS\\VMSDB" but the Directory.Getfiles
responded with directory not found. Does it just not like the Server name
instead of C drive? or is it the 4 back slashes"\\\\"?

Thanks.


Well, since you are using the @ symbol, don't escape the string..IE:

string strATSPath = @"\\support\VMS\VMSDB";

HTH :)

Mythran

Nov 17 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Arsen V. | last post: by
3 posts views Thread by mavrick101 | last post: by
reply views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.