如何添加目录位置到mysql varchar? [英] How to add directory location to mysql varchar?

查看:92
本文介绍了如何添加目录位置到mysql varchar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我查询并添加位置字符串示例:' C:\SomeFolder\SubFolder\image.jpg ',
该查询将数据库中的值设置为' C:SomeFolderSubFolderimagejpg '然后我发现要保存位置,您需要有两个'\' 字符,(像这样 \\ )被视为目录位置,所以你可以让我成为一个字符串函数,你输入位置,函数返回相同的字符串,但加倍的反斜杠?

When I do query and I add the location string example: "'C:\SomeFolder\SubFolder\image.jpg'", the query sets the value in database as "'C:SomeFolderSubFolderimagejpg'" then I found that to save location you need to have two '\' characters, (like this \\) for it to be counted as a directory location, so can you make me a string function that you enter the location and the function returns the same string but with doubled backslashes?

input = 'C:\SomeFolder\SubFolder\image.jpg';
database need to save as 'C:\\SomeFolder\\SubFolder\\image.jpg';


推荐答案

只需用双斜杠替换所有斜杠: p>

Just replace all slashes with double-slashes:

string input = @"C:\SomeFolder\SubFolder\image.jpg";
string query = input.Replace(@"\", @"\\");

这篇关于如何添加目录位置到mysql varchar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆