• Узнать SID текущего пользователя и замена содержимого .xml?

    @papacoca Автор вопроса
    Производит замену слова "C-han-ge-me" на слово "strUser". а нужно заменить на значение типа S-1-5-21-2303912444-598105561-2700407050-1001
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Security.Principal;
    using System.Web.Security;
    using System.IO;
     
    namespace ConsoleApp13
    {
     
        class Program
        {
            
            static void Main(string[] args)
            {
                string strUser = System.Security.Principal.WindowsIdentity.GetCurrent().User.ToString();
                File.WriteAllText("desktop.xml", File.ReadAllText("desktop.xml").Replace("C-han-ge-me", "strUser"));
            }
        }
    }
    Ответ написан
    Комментировать