none
need help in .NET Framework 3.5 RRS feed

  • Question

  • Hello Everyone,

    How can i get the file name and file path of the deleted file with its pid in .net framework 3.5.

    I'm using TraceEvent(KernalTraceEventParser).

    Thanks  


    Thursday, October 5, 2017 2:17 PM

Answers

  • Hi Rajat Kinkhabwala,

    Thank you for posting here.

    If you want to get the file name via process ID using .net framework 3.5, you could try the following code.

      var process = Process.GetProcessById(8952);
                var fullPath = process.MainModule.FileName;
                var fileName = process.MainModule.ModuleName;

    I test it on .net framework 3.5, it works well.

    Best Regards,

    Wendy


    MSDN Community Support
    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, October 10, 2017 2:53 AM
    Moderator

All replies

  • Hi Rajat Kinkhabwala,

    Thank you for posting here.

    If you want to get the file name via process ID using .net framework 3.5, you could try the following code.

      var process = Process.GetProcessById(8952);
                var fullPath = process.MainModule.FileName;
                var fileName = process.MainModule.ModuleName;

    I test it on .net framework 3.5, it works well.

    Best Regards,

    Wendy


    MSDN Community Support
    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, October 10, 2017 2:53 AM
    Moderator
  • Hello,

    session.Source.Kernel.FileIORead += delegate (FileIOReadWriteTraceData data)
                    {
                        try
                        {
                            var process = Process.GetProcessById(data.ProcessID);
                            var fullPath = process.MainModule.FileName;
                            var fileName = process.MainModule.ModuleName;
                            Console.Out.WriteLine(process.ProcessName+"   "+data.ProcessID +"     "+ fileName);

                        }catch(Exception )
                        {
                           var process = Process.GetProcessById(data.ProcessID);

                            Console.Out.WriteLine("Read:" + data.ProcessID);
                        }
                       
                    };

    when i'm running this code and getting an exception of system.componentmodel.win32 what could be the problem and how i can fix it ? can you help me if you know something

    Thanks

    Tuesday, October 10, 2017 5:42 PM
  • Hi Rajat Kinkhabwala,

    I have give the reply in your new thread. I reproduce a system.componentmodel.win32 exception. You could run with suitable platform to fix. And you could try to run as admin maybe helpful.

    Best Regards,

    Wendy


    MSDN Community Support
    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.

    Thursday, October 12, 2017 3:02 AM
    Moderator