コード例 #1
0
        public void Update()
        {
            // We're clearing and recreating the process list each time, but the list is typically long (150-250 processes),
            // so we can't use the same add/remove/update technique we use for packaged apps, because it's too slow.
            Clear();

            IReadOnlyList <ProcessDiagnosticInfo> processes = ProcessDiagnosticInfo.GetForProcesses();

            if (processes != null)
            {
                foreach (ProcessDiagnosticInfo process in processes)
                {
                    BitmapImage image = null;
                    if (process.IsPackaged)
                    {
                        image = defaultAppImage;
                    }
                    else
                    {
                        image = defaultProcessImage;
                    }
                    ProcRowInfo processInfo = new ProcRowInfo(process, image);
                    Add(processInfo);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// request for process info
        /// </summary>
        private void LoadProcesses()
        {
            mainViewModel.ProcessList.Clear();
            List <ProcessDiagnosticInfo> processList = ProcessDiagnosticInfo.GetForProcesses().ToList();

            processList.ForEach(o => mainViewModel.ProcessList.Add(new ProcessInfoModel(o)));
        }
コード例 #3
0
        private void GetProcessDiagnostics()
        {
            try
            {
                ProcessDiagnosticInfo info = ProcessDiagnosticInfo.GetForCurrentProcess();

                //ProcessCpuUsageReport cpuReport = info.CpuUsage.GetReport();
                //TimeSpan kernelTime = cpuReport.KernelTime;
                //TimeSpan userTime = cpuReport.UserTime;

                ProcessMemoryUsageReport memoryReport = info.MemoryUsage.GetReport();
                //ulong nonPagedPool = memoryReport.NonPagedPoolSizeInBytes;
                //ulong pagedPool = memoryReport.PagedPoolSizeInBytes;
                //ulong peakNonPagedPool = memoryReport.PeakNonPagedPoolSizeInBytes;
                //ulong peakPagedPool = memoryReport.PeakPagedPoolSizeInBytes;

                ulong virtualMemory = memoryReport.VirtualMemorySizeInBytes;
                ulong workingSet    = memoryReport.WorkingSetSizeInBytes;
                //ulong peakVirtualMemory = memoryReport.PeakVirtualMemorySizeInBytes;
                //ulong peakWorkingSet = memoryReport.PeakWorkingSetSizeInBytes;

                //ulong pageFaults = memoryReport.PageFaultCount;
                //ulong pageFile = memoryReport.PageFileSizeInBytes;
                //ulong privatePages = memoryReport.PrivatePageCount;
                //ulong peakPageFile = memoryReport.PeakPageFileSizeInBytes;

                virtualMemoryText.Text = string.Format(CultureInfo.CurrentCulture, "{0:N}", (double)virtualMemory / MB);
                workingSetText.Text    = string.Format(CultureInfo.CurrentCulture, "{0:N}", (double)workingSet / MB);
            }
            catch (Exception ex)
            {
                status.Log(ex.Message);
            }
        }
コード例 #4
0
        public IOMonitor(bool monitorIOWrites, bool monitorIOReads, bool monitorIOData, int monitorPeriodInMilliseconds)
        {
            if (!monitorIOWrites && !monitorIOReads && !monitorIOData)
            {
                throw new ArgumentException("At least one flag has to be true.");
            }

            this.monitorIOWrites = monitorIOWrites;
            this.monitorIOReads  = monitorIOReads;
            this.monitorIOData   = monitorIOData;

            this.monitorPerionInMilliseconds = monitorPeriodInMilliseconds;

#if NETFX_CORE
            CurrentProcess = ProcessDiagnosticInfo.GetForCurrentProcess().DiskUsage;
#else
            string processName = Process.GetCurrentProcess().ProcessName;

            if (monitorIOWrites)
            {
                writesCounter = new PerformanceCounter("Process", "IO Write Bytes/sec", processName);
            }
            if (monitorIOReads)
            {
                readsCounter = new PerformanceCounter("Process", "IO Read Bytes/sec", processName);
            }
            if (monitorIOData)
            {
                dataCounter = new PerformanceCounter("Process", "IO Data Bytes/sec", processName);
            }
#endif

            timer = new Timer(DoMonitor, null, Timeout.Infinite, MonitorPeriodInMilliseconds);
        }
コード例 #5
0
ファイル: Func.cs プロジェクト: alexpisquared/MediaPlay
        string cpuLoadReport()
        {
            var rv  = "...";
            var pdi = ProcessDiagnosticInfo.GetForCurrentProcess();
            var cpu = pdi.CpuUsage.GetReport().UserTime;
            var now = DateTimeOffset.Now;
            var pst = now - pdi.ProcessStartTime;

            if (pst == TimeSpan.Zero)
            {
                return("now == prcs start");
            }

            if (_prevt > DateTimeOffset.MinValue)
            {
                var t = now - _prevt;
                var u = cpu - _prevu;
                if (t.TotalMilliseconds > 0)
                {
                    rv = $"{(100d * u.TotalMilliseconds / t.TotalMilliseconds),6:N0} / {(100d * cpu.TotalMilliseconds / pst.TotalMilliseconds):N0} ";
                }
            }

            _prevt = now;
            _prevu = cpu;

            return(rv);
        }
コード例 #6
0
        /// <summary>
        /// 获取所有进程
        /// </summary>
        public ObservableCollection <RunningProcess> GetProcessNow()
        {
            bool judge;
            int  j;

            ObservableCollection <RunningProcess> processes = new ObservableCollection <RunningProcess>();
            var details = ProcessDiagnosticInfo.GetForProcesses().OrderByDescending(x => x.ExecutableFileName);

            foreach (var detail in details)
            {
                if (detail.Parent != null)
                {
                    if ((!detail.ExecutableFileName.Equals("winlogon.exe")) && (!detail.ExecutableFileName.Equals("System")) && (!detail.ExecutableFileName.Equals("svchost.exe")) && (!detail.Parent.ExecutableFileName.Equals("svchost.exe") && (!detail.Parent.ExecutableFileName.Equals("wininit.exe"))))
                    {
                        for (j = 0, judge = false; j < processes.Count; j++)
                        {
                            if (processes[j].id == detail.Parent.ProcessId)
                            {
                                judge = true;
                            }
                        }
                        if (judge == false)
                        {
                            var temp2 = new RunningProcess(detail.ExecutableFileName, detail.ProcessId, detail.Parent.ExecutableFileName, detail.Parent.ProcessId);
                            processes.Add(temp2);
                        }
                    }
                }
            }
            return(processes);
        }
コード例 #7
0
        private async void Page_LoadedAsync(object sender, RoutedEventArgs e)
        {
            foreach (var info in await AppDiagnosticInfo.RequestInfoAsync())
            {
                /*Items.Add(new AppInfo
                 * {
                 *  Id = info.AppInfo.Id,
                 *  PackageFamilyName = info.AppInfo.PackageFamilyName,
                 *  Description = info.AppInfo.DisplayInfo.Description,
                 *  DisplayName = info.AppInfo.DisplayInfo.DisplayName,
                 *  AppUserModelId = info.AppInfo.AppUserModelId,
                 * });*/
            }

            foreach (var info in ProcessDiagnosticInfo.GetForProcesses())
            {
                /*ProcessItems.Add(new ProcessInfo
                 * {
                 *  ExecutableFileName = info.ExecutableFileName,
                 *  ProcessId = $"{info.ProcessId}",
                 *  CpuUsage = $"{info.CpuUsage.GetReport().UserTime:hh':'mm':'ss}",
                 *  MemoryUsage = $"{info.MemoryUsage.GetReport().WorkingSetSizeInBytes:N0}",
                 * });*/
            }
        }
コード例 #8
0
        public ProcessInfoModel(ProcessDiagnosticInfo process)
        {
            ProcessCpuUsageReport cpuReport = process.CpuUsage.GetReport();

            if (cpuReport != null)
            {
                TimeSpan cpuUsageTime = cpuReport.KernelTime + cpuReport.UserTime;
                CpuUsageTime = string.Format("{0:hh\\:mm\\:ss}", cpuUsageTime);
            }
            ProcessDiskUsageReport diskReport = process.DiskUsage.GetReport();

            if (diskReport != null)
            {
                DiskBytesCount = diskReport.BytesReadCount + diskReport.BytesWrittenCount;
            }
            ProcessMemoryUsageReport memoryReport = process.MemoryUsage.GetReport();

            if (memoryReport != null)
            {
                PageFileSize   = memoryReport.PageFileSizeInBytes;
                WorkingSetSize = memoryReport.WorkingSetSizeInBytes;
            }
            ProcessId = process.ProcessId;
            ExeName   = process.ExecutableFileName;
        }
コード例 #9
0
        /// <summary>
        /// Use this function if you don't want the message to be batched
        /// </summary>
        /// <param name="txt"></param>
        public static void SystemLog(string txt)
        {
            string toPrint;

            lock (_stringBuilder)
            {
#if NETFX_CORE
                string currentTimeString = DateTime.UtcNow.ToString("dd/mm/yy hh:ii:ss");
                string processTimeString = (DateTime.UtcNow - ProcessDiagnosticInfo.
                                            GetForCurrentProcess().ProcessStartTime.DateTime.ToUniversalTime()).ToString();
#else
                string currentTimeString = DateTime.UtcNow.ToLongTimeString(); //ensure includes seconds
                string processTimeString = (DateTime.UtcNow - Process.GetCurrentProcess().StartTime.ToUniversalTime()).ToString();
#endif

                _stringBuilder.Length = 0;
                _stringBuilder.Append("[").Append(currentTimeString);
                _stringBuilder.Append("][").Append(processTimeString);
                _stringBuilder.Length = _stringBuilder.Length - 3; //remove some precision that we don't need
                _stringBuilder.Append("] ").AppendLine(txt);

                toPrint = _stringBuilder.ToString();
            }

#if !UNITY_EDITOR
#if !NETFX_CORE
            System.Console.WriteLine(toPrint);
#else
            //find a way to adopt a logger externally, if this is still needed
#endif
#else
            UnityEngine.Debug.Log(toPrint);
#endif
        }
コード例 #10
0
ファイル: Logging.cs プロジェクト: freistli/UWPDebugging
        public void LogMessage(string message)
        {
            var processId = ProcessDiagnosticInfo.GetForCurrentProcess().ProcessId;

            singleInstance.logger.Information(processId + " " + message);

            Debug.WriteLine("Message " + message);
        }
コード例 #11
0
 public AddProcess()
 {
     this.InitializeComponent();
     foreach (ProcessDiagnosticInfo ii in ProcessDiagnosticInfo.GetForProcesses())
     {
         procces.Items.Add(ii.ExecutableFileName);
     }
 }
コード例 #12
0
 public ProcRowInfo(ProcessDiagnosticInfo p, BitmapImage bmp)
 {
     pdi          = p;
     cpuReport    = pdi.CpuUsage.GetReport();
     diskReport   = pdi.DiskUsage.GetReport();
     memoryReport = pdi.MemoryUsage.GetReport();
     Logo         = bmp;
     AppType      = p.IsPackaged ? "Packaged" : "Win32";
 }
コード例 #13
0
        private int getMemoryPerformance()
        {
            IReadOnlyList <ProcessDiagnosticInfo> list = ProcessDiagnosticInfo.GetForProcesses();

            var  a = MemoryManager.GetProcessMemoryReport();
            long b = (long)a.TotalWorkingSetUsage;
            long c = (long)a.PrivateWorkingSetUsage;

            return((int)(c * 100 / b));
        }
コード例 #14
0
        private async Task <IList <TableRowView> > LoadRowsAsync(CancellationToken token, uint count, int baseIndex)
        {
            var result = await _rowsList.LoadRowsAsync(token, count, baseIndex);

            ulong memSize = ProcessDiagnosticInfo.GetForCurrentProcess().MemoryUsage.GetReport().WorkingSetSizeInBytes;

            StatusText.Text = string.Format("total: {0:N0} | cached: {1:N0} | memory used: {2}",
                                            _rowsList.MaxItemCount, _rowsList.CachedRowsCount, ((long)memSize).ToFileSizeUiString());

            return(result);
        }
コード例 #15
0
ファイル: Temperature.cs プロジェクト: sven-borden/Monitoring
        public Temperature()
        {
            var a = ProcessDiagnosticInfo.GetForProcesses();

            foreach (var i in a)
            {
                string s = i.CpuUsage.GetReport().KernelTime.TotalMilliseconds.ToString();

                s += 1;
            }
        }
コード例 #16
0
        static MessageSourceFactory()
        {
#if WINDOWS_UAP
            _processId = ProcessDiagnosticInfo.GetForCurrentProcess().ProcessId;
            var localHost = NetworkInformation.GetHostNames().FirstOrDefault(host => host.DisplayName.Contains(".local"));
            _machineName = localHost?.DisplayName.Replace(".local", "");
#else
            _processId   = Process.GetCurrentProcess().Id;
            _machineName = Process.GetCurrentProcess().MachineName;
#endif
        }
コード例 #17
0
    public static async Task <bool> CheckForRunningProcess(string processName)
    {
        //Requests permission for app.
        await AppDiagnosticInfo.RequestAccessAsync();

        //Gets the running processes.
        var processes = ProcessDiagnosticInfo.GetForProcesses();

        //Returns result of searching for process name.
        return(processes.Any(processDiagnosticInfo => processDiagnosticInfo.ExecutableFileName.Contains(processName)));
    }
コード例 #18
0
        private static string GetUwpId(Window application)
        {
            var process = ProcessDiagnosticInfo.TryGetForProcessId((uint)application.process.Id);

            foreach (var appDiagnosticInfo in process.GetAppDiagnosticInfos())
            {
                return(appDiagnosticInfo.AppInfo.AppUserModelId);
            }

            return("None");
        }
コード例 #19
0
ファイル: LogPage.xaml.cs プロジェクト: waitenfor/MoePicture
 public LogLineList() : base()
 {
     Add(new LogLineItem("Memory(MB)",
                         new Func <float>(() => { return(MemoryManager.AppMemoryUsage / 1_000_000); })));
     Add(new LogLineItem("CPU User Time (Second)",
                         new Func <float>(() => { return((float)ProcessDiagnosticInfo.GetForCurrentProcess().CpuUsage.GetReport().UserTime.TotalSeconds); })));
     Add(new LogLineItem("CPU Kernel Time (Second)",
                         new Func <float>(() => { return((float)ProcessDiagnosticInfo.GetForCurrentProcess().CpuUsage.GetReport().KernelTime.TotalSeconds); })));
     Add(new LogLineItem("Disk Read", new Func <float>(() => { return(ProcessDiagnosticInfo.GetForCurrentProcess().DiskUsage.GetReport().ReadOperationCount); })));
     Add(new LogLineItem("Disk Write",
                         new Func <float>(() => { return(ProcessDiagnosticInfo.GetForCurrentProcess().DiskUsage.GetReport().WriteOperationCount); })));
 }
コード例 #20
0
        private ulong GetProcessPrivateCommit(ProcessDiagnosticInfo process)
        {
            ulong privateCommit = 0;

            if (process.MemoryUsage != null)
            {
                ProcessMemoryUsageReport pmReport = process.MemoryUsage.GetReport();
                if (pmReport != null)
                {
                    privateCommit = pmReport.PageFileSizeInBytes;
                }
            }
            return(privateCommit);
        }
コード例 #21
0
        private int getCpuPerformance()
        {
            IReadOnlyList <ProcessDiagnosticInfo> list = ProcessDiagnosticInfo.GetForProcesses();

            double sumUsage = 0, sumTotal = 0;

            foreach (var item in list)
            {
                sumUsage += item.CpuUsage.GetReport().UserTime.Milliseconds;
                sumTotal += item.CpuUsage.GetReport().UserTime.Milliseconds + item.CpuUsage.GetReport().KernelTime.Milliseconds;
            }

            sumTotal = (sumUsage * 100 / sumTotal);

            return((int)sumTotal);
        }
コード例 #22
0
        private static ImageSource GetUwpIcon(Window application)
        {
            var uwpProcess = ProcessDiagnosticInfo.TryGetForProcessId((uint)application.process.Id);

            var appInfos     = uwpProcess.GetAppDiagnosticInfos();
            var appInfoCount = appInfos.Count;
            var appInfo      = appInfos[0].AppInfo;
            var name         = appInfo.AppUserModelId;


            var shellItem =
                InstalledApplications.First(item => ApplicationUtils.GetAppModelUserId(item) == appInfo.AppUserModelId);
            var bitmap = ApplicationUtils.GetIcon(shellItem);


            return(bitmap);
        }
コード例 #23
0
        private static bool NotSuspended(Window window)
        {
            var diagnosticInfo = ProcessDiagnosticInfo.TryGetForProcessId((uint)window.process.Id);

            if (!diagnosticInfo.IsPackaged)
            {
                return(true);
            }

            var appDiagnosticInfos = diagnosticInfo.GetAppDiagnosticInfos();
            var anySuspended       = appDiagnosticInfos.Any(info =>
                                                            info.GetResourceGroups().Any(resourceInfo =>
                                                                                         resourceInfo.GetStateReport().ExecutionState == AppResourceGroupExecutionState.Suspended
                                                                                         )
                                                            );

            return(!anySuspended);
        }
コード例 #24
0
        public MainPage()
        {
            this.InitializeComponent();

            IReadOnlyList <ProcessDiagnosticInfo> processes = ProcessDiagnosticInfo.GetForProcesses();

            if (processes != null)
            {
                foreach (ProcessDiagnosticInfo process in processes)
                {
                    string exeName = process.ExecutableFileName;
                    string pid     = process.ProcessId.ToString();

                    systemProcesses.Add(new Process {
                        Name = exeName, ProcessID = pid
                    });
                    Debug.WriteLine(exeName + " " + pid);
                }
            }
        }
コード例 #25
0
        /// <summary>
        /// 获取所有进程(接口实现) : 包括Win32 与 UWP
        /// </summary>
        /// <returns>ObservableCollection<Process></returns>
        public ObservableCollection <Process> GetProcessNow()
        {
            ObservableCollection <Process> processes = new ObservableCollection <Process>();

            //取出所有进程
            IReadOnlyList <ProcessDiagnosticInfo> details = ProcessDiagnosticInfo.GetForProcesses();

            foreach (ProcessDiagnosticInfo detail in details)
            {
                if (detail.Parent != null)
                {
                    if ((!detail.ExecutableFileName.Equals("winlogon.exe")) && (!detail.ExecutableFileName.Equals("svchost.exe")) && (!detail.Parent.ExecutableFileName.Equals("wininit.exe")))
                    {
                        var temp2 = new Process(detail.ExecutableFileName, "2333", 3);
                        processes.Add(temp2);
                    }
                }
            }
            return(processes);
        }
コード例 #26
0
ファイル: MemoryMonitor.cs プロジェクト: wondial/STS.General
        public MemoryMonitor(bool monitorPagedMemory, bool monitorWorkingSet, bool monitorVirtualMemory, int monitorPeriodInMilliseconds = 500)
        {
            if (!monitorPagedMemory && !monitorWorkingSet && !monitorVirtualMemory)
            {
                throw new ArgumentException("At least one flag has to be true.");
            }

            this.monitorPagedMemory          = monitorPagedMemory;
            this.monitorWorkingSet           = monitorWorkingSet;
            this.monitorVirtualMemory        = monitorVirtualMemory;
            this.monitorPeriodInMilliseconds = monitorPeriodInMilliseconds;

#if NETFX_CORE
            CurrentProcess = ProcessDiagnosticInfo.GetForCurrentProcess().MemoryUsage;
#else
            CurrentProcess = Process.GetCurrentProcess();
#endif

            timer = new Timer(DoMonitor, null, Timeout.Infinite, MonitorPeriodInMilliseconds);
        }
コード例 #27
0
ファイル: CpuMonitor.cs プロジェクト: wondial/STS.General
        /// <summary>
        /// When used in .NET Core not supported monitoring of privileged time.
        /// </summary>
        /// <param name="monitorPrivilegedTime">If truth be monitored the privileged time. Not supported for .Net core.</param>
        /// <param name="monitorProcessorTime">If truth be monitored the processor time.</param>
        /// <param name="monitorUserTime">If truth be monitored the user time.</param>
        /// <param name="monitorPeriodInMilliseconds">The time interval between invocations of refresh, in milliseconds. Specify Timeout.Infinite to disable periodic signaling.</param>
        public CPUMonitor(bool monitorPrivilegedTime, bool monitorProcessorTime, bool monitorUserTime, int monitorPeriodInMilliseconds = 500)
        {
            if (!monitorPrivilegedTime && !monitorProcessorTime && !monitorUserTime)
            {
                throw new ArgumentException("At least one flag has to be true.");
            }

            this.monitorPrivilegedTime = monitorPrivilegedTime;
            this.monitorProcessorTime  = monitorProcessorTime;
            this.monitorUserTime       = monitorUserTime;

            this.monitorPeriodInMilliseconds = monitorPeriodInMilliseconds;

#if NETFX_CORE
            if (monitorPrivilegedTime)
            {
                throw new NotSupportedException("Not support in .Net Core.");
            }

            CurrentProcess = ProcessDiagnosticInfo.GetForCurrentProcess().CpuUsage;
#else
            string processName = Process.GetCurrentProcess().ProcessName;

            if (monitorPrivilegedTime)
            {
                privilegedTimeCounter = new PerformanceCounter("Process", "% Privileged Time", processName);
            }
            if (monitorProcessorTime)
            {
                processorTimeCounter = new PerformanceCounter("Process", "% Processor Time", processName);
            }
            if (monitorUserTime)
            {
                userTimeCounter = new PerformanceCounter("Process", "% User Time", processName);
            }
#endif

            timer = new Timer(DoMonitor, null, Timeout.Infinite, MonitorPeriodInMilliseconds);
        }
コード例 #28
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            lock ( ActiveTask )
            {
                uint PID = ProcessDiagnosticInfo.GetForCurrentProcess().ProcessId;
                if (!string.IsNullOrEmpty(ActiveTask))
                {
                    Logger.Log(ID, "Another Task is already running: " + ActiveTask + " | " + PID, LogType.INFO);
                    taskInstance.GetDeferral().Complete();
                    return;
                }

                ActiveTask = string.Format("{0}: {1}", taskInstance.Task.Name, PID);
            }

            Deferral = taskInstance.GetDeferral();

            // Associate a cancellation handler with the background task.
            taskInstance.Canceled += new BackgroundTaskCanceledEventHandler(OnCanceled);

            try
            {
                Retrying = (taskInstance.Task.Name == TASK_RETRY);

                await Init();

                using (CanvasDevice = Image.CreateCanvasDevice())
                {
                    await UpdateSpiders();
                }
            }
            finally
            {
                ActiveTask = "";
                Deferral.Complete();
            }
        }
コード例 #29
0
 int IPlatform.GetCurrentProcessId() => (int)ProcessDiagnosticInfo.GetForCurrentProcess().ProcessId;
コード例 #30
0
        private async void Timer_Tick(object sender, object e)
        {
            Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
            try
            {
                var s = "";
                Windows.Storage.StorageFile sampleFile = await storageFolder.GetFileAsync("procs.txt");

                list.Items.Clear();
                foreach (var i in (await Windows.Storage.FileIO.ReadTextAsync(sampleFile)).Split('\n'))
                {
                    if (i.IndexOf('~') != -1)
                    {
                        if (i.Split('~')[0] == "default" && s == "")
                        {
                            s = i.Split('~')[1];
                        }
                        else
                        {
                            foreach (ProcessDiagnosticInfo ii in ProcessDiagnosticInfo.GetForProcesses())
                            {
                                if (i.Split('~')[0] == ii.ExecutableFileName)
                                {
                                    s = i.Split('~')[1];
                                }
                            }
                        }
                        Grid g = new Grid()
                        {
                            HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch
                        };
                        ListViewItem lvi = new ListViewItem()
                        {
                            Content = g, HorizontalAlignment = HorizontalAlignment.Stretch, HorizontalContentAlignment = HorizontalAlignment.Stretch
                        };
                        g.Children.Add(new TextBlock()
                        {
                            Text = i.Split('~')[0], HorizontalAlignment = HorizontalAlignment.Left
                        });
                        g.Children.Add(new TextBlock()
                        {
                            Text = i.Split('~')[1], HorizontalAlignment = HorizontalAlignment.Right
                        });
                        list.Items.Add(lvi);
                    }
                }
                if (s != singlton.status)
                {
                    singlton.status = s;
                }
                answTextBlock.Text = s;
                //await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Test~System\nexplorer.exe~играет в проводник windows");
            }
            catch (FileNotFoundException ex)
            {
                Windows.Storage.StorageFile sampleFile = await storageFolder.CreateFileAsync("procs.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting);

                answTextBlock.Text = ex.Message;
                await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "default~ ");
            }
            catch (Exception ex)
            {
                answTextBlock.Text = ex.Message;
            }
        }