Problem with asmx webmethod that uses Mysql Load Data local infile
When I use the following in a webmethod:
string mysqlsPath = Server.MapPath("applog.txt");
command.CommandText = "LOAD DATA LOCAL INFILE '" + mysqlsPath + "' INTO TABLE numbers FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'";
command.ExecuteNonQuery();
connection.Close();
I get Error LOAD DATA LOCAL INFILE ---> Could not find file 'c:\windows\system32\inetsrv\inetpubwwwrootwebservicesapplog.txt'
When looking开发者_如何学运维 at this error i noticed that after "inet" its dropping the "\" between the rest of the directories, what could be causing this and how can I fix it?
You'll need to escape the mysqlsPath variale first.
Something like this would do the trick
mysqlsPath = mysqlsPath.Replace(@"\", @"\\");
This will convert the \ to \ so the c# won't remove it.
精彩评论