locked
No permission set for resource s before accessing it RRS feed

  • Question

  • I am using Klockwork analysis, i am getting "No permission set for resource s before accessing it" in s.WriteLine.

    using (StreamWriter s = new StreamWriter("C:\Users\...\sample.txt"))
    {
       s.WriteLine("Hello"); ----> Problem in this line

    }

    Regards,

    Tulasikumar

    • Moved by Hart Wang Wednesday, August 23, 2017 9:01 AM
    Thursday, August 17, 2017 6:42 AM

All replies

  • Hi,

    Thank you for posting here.

    I try to create a console project with the following code, I can run successfully and get sample.text, you could reference code.

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (StreamWriter writer =
                new StreamWriter("sample.txt"))
                {
                    writer.Write("Word ");
                    writer.WriteLine("word 2");
                    writer.WriteLine("Line");
                    writer.WriteLine("Line");
                    writer.WriteLine("Line");
                }
    
            }
        }
    }
    

    The Write method does not append a newline. The WriteLine methods append a newline "\r\n" at each call.

    The program creates the file "sample.txt", which is in the same directory as the application.

    >>" No permission set for resource s before accessing it  "

    I don't encounter your issue, could you please provide a reproducing demo on one drive to test?

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 18, 2017 1:57 AM
  • Hi Hart, 

    Actually this issue is reproduce, once you run your code with Klockwork tool.

    Note: Klockwork  is tool is it will make ensure, we are following coding standards.

    Regards,

    Tulasikumar

    Friday, August 18, 2017 4:11 AM
  • Hi G M Tulasi kumar,

    Thank you for your feedback. 

    Based on my search the Klockwork  tool belongs to the third product. 

    According to MSDN policy, i will move the case to off-topic forum.  You could post the issue on their support website.

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, August 22, 2017 2:15 AM