How to connect to Share-Drive using Simple Impersonation Nuget package with C#?
Today, I gonna show u how we can connect the Share Drive using Simple Impersonation C# plugin. First, we need to install the Nuget package to your C# Project.
PM> Install-Package SimpleImpersonation -Version 3.0.0
Usagevar credentials = new UserCredentials(".", "<username>", "<password>");
Impersonation.RunAsUser(credentials, LogonType.NewCredentials, () =>
{
DirectoryInfo directory = new DirectoryInfo(@"\\<share-path>\<share-folder>");
//Get Directory List
DirectoryInfo[] directoryList = directory.GetDirectories();
for (int i = 0; i < directoryList.Length; i++)
{
Console.WriteLine(directoryList[i]);
}
//Get File List
FileInfo[] fileList = directory.GetFiles();
for (int i = 0; i < fileList.Length; i++)
{
Console.WriteLine(fileList[i]);
}
});
That’s it. I hope this will help. 🙂
Source: https://github.com/mj1856/SimpleImpersonation
It’s awesome designed for me to have a website, which is useful in favor of my experience.
thanks admin
Very good info. Lucky me I ran across your blog by chance (stumbleupon).
I’ve saved it for later!
Thanks for sharing your thoughts on hogwash. Regards
Awesome issues here. I am very satisfied to see your article.
Thanks so much and I am looking ahead to touch you. Will you kindly drop me a e-mail?
I am truly happy to glance at this web site posts which contains plenty of
helpful data, thanks for providing these information.
It’s a pity you don’t have a donate button! I’d without a doubt donate to this
superb blog! I suppose for now i’ll settle for book-marking and adding your RSS feed to my Google account.
I look forward to fresh updates and will share this website with
my Facebook group. Talk soon!
Hello, I wish for to subscribe for this webpage to get newest updates, therefore where can i
do it please assist.
Great blog you have got here.. It’s difficult to find high-quality writing like yours nowadays.
I really appreciate individuals like you! Take care!!
I was curious if you ever thought of changing the structure of
your blog? Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people could connect with it
better. Youve got an awful lot of text for only having 1 or two pictures.
Maybe you could space it out better?
Der Artikel ist wirklich gut. Das Thema hat mich schon sehr lange interessiert und ich konnte hier noch
einiges weiterführendes finden. Ich freue mich,
weitere Neuigkeiten zu lesen. Danke und Grüße aus Heidelberg Marco Feindler
excellent ѕubmit, very informative. I ԝonder why the other experts of this sector
don’t understand thiѕ. Yօu must proceed your writing.
I am sure, you’ve а great readerѕ’ bаse already!
This is very fascinating, You’re an overly skilled blogger.
I have joined your feed and stay up for in search of more of your excellent post.
Additionally, I have shared your site in my social networks
I blog frequently and I genuinely appreciate your content.
This article has truly peaked my interest. I am going to book mark your blog
and keep checking for new information about once per week.
I opted in for your RSS feed as well.
You can definitely see your expertise in the work you write.
The world hopes for more passionate writers like you who are
not afraid to mention how they believe. All the time follow your heart.
delivery before holidays
hi nice blogs
good!!nice blog