WinServer 2016 (Windows 10) + IIS 10 + MS Office 2010. The asp.net application cannot create and (or) save an Excel file (txt file too) in a local folder (on another disk). In this case , an existing file with the same name deletes, and in development mode (launching a project from Visual Studio 2015), the file is created and deleted. Can anyone come across this?

enter image description here

enter image description here

Permissions (Full access for all groups) for the folder in which the file is written \ deleted.

UPD 0 - File Creation Code

// Создать книгу и лист _Application excel = new Application(); Workbook wb = excel.Workbooks.Add(XlWBATemplate.xlWBATWorksheet); Worksheet ws = wb.Worksheets[1]; 

UPD 1 - Do not roll, txt-file also does not create.

  // Сохранить файл и выйти из него try { wb.SaveAs(path); File.Create(@"f:\testAutorep\234.txt"); } catch { File.Create(@"f:\testAutorep\123.txt"); } 

UPD 2 When creating an Excel file - an exception:

Microsoft Excel cannot open or save documents due to insufficient memory or disk space. • To free up memory, close unnecessary books or programs. • To free up disk space, delete unnecessary files from this disk.

SOLVED - https://bloglisa.ru/?p=1419 Solution: Go to the registry editor, find the HKEY_CURRENT_USER \ Software \ Microsof t \ Windows \ CurrentVersion \ Explorer \ User Shell Folders section, in this section find the “Cache” parameter and change its, for example, on c: \ temp (temp directory on the C: drive must be present). After the change, restarting the computer is not necessary.

PS If this option does not help, then try changing the environment variables (system and user) temp and tmp to c: \ temp

  • one
    Well, what error does it write? - tym32167 4:16 pm
  • one
    Yes, and the code in the studio generating the document, plus the path to the folder. Maybe you write not where you want - Dev
  • one
    Problem in the user from under which iis works. Try working in the application folder. usually create the App_Data directory and already save files in it (you must also give write access to this directory) - Alexey Obukhov
  • 2
    Do not use absolute paths, only relative. Imagine that you have flooded your site on a hosting. There may not be a disk f. And most importantly, no one will allow you to access it. Therefore, only paths relative to the folder of your web application. - Alexander Petrov
  • one
    This question should be closed, because it is “decided”, but no answer is given. - Enikeyschik pm

1 answer 1

Solution: Enter the registry editor, find the HKEY_CURRENT_USER \ Software \ Microsof t \ Windows \ CurrentVersion \ Explorer \ User Shell Folders section, in this section find the “Cache” parameter and change it, for example, to c: \ temp (temp directory on the disk C: must be present). After the change, restarting the computer is not necessary.

PS If this option does not help, then try changing the environment variables (system and user) temp and tmp to c: \ temp