"拒绝访问路径[...]"即使我以管理员身份运行

时间:2015-11-10 08:11:32

标签: c# .net windows windows-8

我的程序不喜欢我的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);

    }

newDataPathC:\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?

0 个答案:

没有答案