我的程序不喜欢我的File.Copy
,正如它所说的
访问路径' C:\ Users \ Me \ Documents \ Visual Studio 2013 \项目\不友好\不友好\ BIN \调试\数据'被拒绝
当我尝试调用我的函数时
public void AddFriendList ( string newDataPath )
{
// dataPath: Full file path to Facebook data file being added
string newFriendsPath = System.IO.Path.Combine(new string [] { newDataPath,"html","friends.htm"});
using ( StreamReader sr = new StreamReader(this._datadir) )
{
Match friendsULs = DataReader._lregx.Match(sr.ReadToEnd());
if ( !friendsULs.Success )
{
throw new Exception(String.Format("Couldn't find exactly one piece of HTML matching regex {0}",
DataReader._lregx.ToString()));
}
Dictionary<string, int> friendMap = new Dictionary<string, int>();
foreach ( Match thisFriendRegex in DataReader._fregx.Matches(friendsULs.ToString()) )
{
var thisFriendString = thisFriendRegex.ToString();
if ( friendMap.ContainsKey(thisFriendString) )
{
++friendMap[thisFriendString];
}
else
{
friendMap[thisFriendString] = 1;
}
_fhist.Add(new FriendList { friendNames = friendMap, timestamp = File.GetCreationTime(newFriendsPath) });
}
}
// Copy new data Facebook data into repository
File.Copy(newDataPath, this._datadir);
}
newDataPath
为C:\Users\Me\Desktop\facebook_data
。我已尝试以管理员身份运行,但仍然收到错误。
我的项目的全部内容可以在https://github.com/jamkin/Unfriendly/blob/master/Unfriendly/DataReader.cs看到,顺便说一下,看起来GitHub不知道如何处理@"..."
字符串,因为它
private static readonly string _instructsBody = String.Format(@"AddFriendList <FacebookDataPath>: Adds to reposistory the instance of Facebook data found at FacebookDataPath\n
Example usage: AddFriendList C:\Users\Jamin\Desktop\facebook_data_1\n
{0}\n
PrintInstructions: Prints instructions (like you just did!)\n
{0}\n
CompareLastTwo: Shows difference between latest two friends lists in repository",
new String('-', DataReader._instructsHeader.Length));
有没有办法写这个而不是混淆GitHub?