Click here to Skip to main content
15,918,258 members
Home / Discussions / C#
   

C#

 
QuestionReading a filepath string from a table field and escapes are automatically added. Pin
Doncal7-Mar-14 4:52
Doncal7-Mar-14 4:52 
Hi Guys,

Im trying to retrieve a part of a string (a filepath and name) from a field.
However when I do, c# "helpfully" automatically escapes the string.
So instead of the string: C:\folderpath\filename.doc
I end up with: C:\\folderpath\\filename.doc
I've tried using the string.Replace funciton to remove the extra rubbish, but nothing happens.
I've also tried using Regex, but it just complains that it doesnt know what "\f" is.
I've tried adding "@" to the beginning of the string retrieval, but that doesnt help either.

Im running a sql query
C#
using (SqlCommand cmd = new SqlCommand("Select Address1, Address2, LinkedDoc, Recid from Contsupp2 Where Rectype = 'L' AND U_ADDRESS1 Like @param", conn))
{
  cmd.Parameters.Add("param", SqlDbType.VarChar,10).Value = @"S:\RWE%";
  using (SqlDataReader reader = cmd.ExecuteReader())
  {
    txt.Clear();
    while (reader.Read())
    {
      string strOrigFilePath = (reader.GetString(2).Substring(reader.GetString(2).IndexOf("FILENAME=") + 9));



Any suggestions as to how I can return a normal string without c# messing it up?

Thanks
AnswerRe: Reading a filepath string from a table field and escapes are automatically added. Pin
Richard Deeming7-Mar-14 5:38
mveRichard Deeming7-Mar-14 5:38 
QuestionBank Transfer Form Pin
Cornille Michiel7-Mar-14 3:31
professionalCornille Michiel7-Mar-14 3:31 
Questionrefferences Pin
Mawande Ngoma7-Mar-14 2:38
Mawande Ngoma7-Mar-14 2:38 
AnswerRe: refferences Pin
Peter Leow7-Mar-14 3:05
professionalPeter Leow7-Mar-14 3:05 
Questiondatagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
shrikanth_BG7-Mar-14 0:48
shrikanth_BG7-Mar-14 0:48 
AnswerRe: datagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
Eddy Vluggen7-Mar-14 7:15
professionalEddy Vluggen7-Mar-14 7:15 
GeneralRe: datagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
shrikanth_BG9-Mar-14 20:06
shrikanth_BG9-Mar-14 20:06 
Questionerror connection c# with oracle 11xe Pin
honar.cs6-Mar-14 21:28
honar.cs6-Mar-14 21:28 
AnswerRe: error connection c# with oracle 11xe Pin
Richard MacCutchan6-Mar-14 22:00
mveRichard MacCutchan6-Mar-14 22:00 
AnswerRe: error connection c# with oracle 11xe Pin
Pete O'Hanlon6-Mar-14 22:00
mvePete O'Hanlon6-Mar-14 22:00 
GeneralRe: error connection c# with oracle 11xe Pin
honar.cs7-Mar-14 1:14
honar.cs7-Mar-14 1:14 
QuestionExpandoObject and Serialization of Anonymous Types ? Pin
BillWoodruff6-Mar-14 15:48
professionalBillWoodruff6-Mar-14 15:48 
AnswerRe: ExpandoObject and Serialization of Anonymous Types ? Pin
Eddy Vluggen6-Mar-14 22:20
professionalEddy Vluggen6-Mar-14 22:20 
GeneralRe: ExpandoObject and Serialization of Anonymous Types ? Pin
BillWoodruff7-Mar-14 1:39
professionalBillWoodruff7-Mar-14 1:39 
AnswerRe: ExpandoObject and Serialization of Anonymous Types ? Pin
Eddy Vluggen7-Mar-14 6:49
professionalEddy Vluggen7-Mar-14 6:49 
GeneralRe: ExpandoObject and Serialization of Anonymous Types ? Pin
BillWoodruff7-Mar-14 14:11
professionalBillWoodruff7-Mar-14 14:11 
GeneralRe: ExpandoObject and Serialization of Anonymous Types ? Pin
Eddy Vluggen7-Mar-14 23:26
professionalEddy Vluggen7-Mar-14 23:26 
QuestionSystem.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 5:34
computerpublic6-Mar-14 5:34 
AnswerRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Andrew x646-Mar-14 5:42
professionalRichard Andrew x646-Mar-14 5:42 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 5:48
computerpublic6-Mar-14 5:48 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Andrew x646-Mar-14 5:50
professionalRichard Andrew x646-Mar-14 5:50 
AnswerRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Deeming6-Mar-14 5:50
mveRichard Deeming6-Mar-14 5:50 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 6:13
computerpublic6-Mar-14 6:13 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Deeming6-Mar-14 6:47
mveRichard Deeming6-Mar-14 6:47 

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.