c# mysql 字段写入文件路径异常问题

   c# mysql 写入文件路径信息 ,mysql中"\"是转义字符,所以写入数据中 文件路径 d:\123\123.txt  就会变成d:123123.txt 

在c#"\"也是转义字符 所以我们定义一个路径 string str = "d:\\123\\123.txt";  要保证写入mysql正常就需要将str变成 str="d:\\\\123\\\\123.txt"; 

我们可以采用 str = str.replace("\\","\\\\"); 

posted @ 2016-05-18 19:55  旗木卡卡赵赵  阅读(598)  评论(0编辑  收藏  举报