TLSharp icon indicating copy to clipboard operation
TLSharp copied to clipboard

web app faces `Access to the path 'C:\\Program Files (x86)\\IIS Express\\session.dat' is denied.`

Open imanf94 opened this issue 7 years ago • 3 comments

I installed TLSharp nuget package (v 0.1.0.274) in a mvc web app and try to use it, but it gives Access denied error in this line:

var client = new TelegramClient(3887, "78b0dcedc3e3b75a9ee63a0e1e604")

Error:

Access to the path 'C:\Program Files (x86)\IIS Express\session.dat' is denied.

so i tried to change permissions of that folder but it didn't solve anything.

I tested the package in a console app and it works properly I think because the session.dat file was made in /Bin/Debug/session.dat but in web app it try to use \IIS Express folder to make session file) How can i solve this problem? Regards

Here is my complete code:

static async Task<long> GetSeenCount(string channelPublicLink, long postId)
        {
            try
            {
                var client = new TelegramClient(1887, "78b0dced01c3ba75a9ee63a0e1e604");//Error
                await client.ConnectAsync();
                var hash = await client.SendCodeRequestAsync("+195916383");
                var code = "<code_from_telegram>"; // you can change code in debugger    
                var user0 = await client.MakeAuthAsync("+195916383", hash, code);
                //.... other functions ....
            }
        }
                

imanf94 avatar Sep 26 '17 07:09 imanf94

Right click Visual Studio, "Run as administrator"

skoenveter avatar Sep 26 '17 20:09 skoenveter

Do you need to save sessions? If so, you have to implement ISessionStore interface, to save the session somewhere else, not in a file. If you don't need that, then just use a FakeSessionStore like this: _client = new TelegramClient(_telegramApiId, _telegramApiHash, new FakeSessionStore());

dvygolov avatar Sep 27 '17 10:09 dvygolov

What I need do if i want save sessions in file?

RomanSoloweow avatar Jul 29 '20 10:07 RomanSoloweow