asp.net在其他服務器中創建文件夾和文件

[英]asp.net create folder and file in other server


In my asp.net application I have an option to take photographs, these photographs should not store the hosting server, the photographs should be stored on another server. (\192.168.1.103\ca\photos\ I use this code

在我的asp.net應用程序中,我可以選擇拍照,這些照片不應該存儲托管服務器,照片應該存儲在另一台服務器上。 (\ 192.168.1.103 \ ca \ photos \我使用此代碼

public void EstructuraReclamo(string Producto, string Poliza, string Sucursal,string Reclamo, string Item) {
string Mensaje = string.Empty;
string DirServidor = DireccionIP(ref Mensaje, "SCANDATOS", Sucursal, "RECLAMOS");           
try
{
    string DirReclamo =DirServidor + Producto + @"\" + Poliza + @"\Item" + Item + @"\" + Reclamo;
    if (!System.IO.Directory.Exists(DirReclamo)){
        System.IO.Directory.CreateDirectory(DirReclamo);
    }
    System.Data.DataTable dtSubdirectorios = ListaSubDirectorio(ref Mensaje, "SCANRECLAMO");
    foreach (System.Data.DataRow dr in dtSubdirectorios.Rows) { 
        string SubDir = DirReclamo + @"\" + dr["apa_glosa"].ToString();
        if (!System.IO.Directory.Exists(SubDir))
            System.IO.Directory.CreateDirectory(SubDir);
    }

}
catch (Exception ex){
    Mensaje = ex.Message.ToString();
}

But the folders are not created? When I execute the program from VS2010 the folders are created, but when publish the site the folders are no created How I can solve this problem?

但是文件夾沒有創建?當我從VS2010執行程序時,會創建文件夾,但是在發布站點時,文件夾沒有創建我怎么能解決這個問題?

The version IIS is 6.0

IIS版本是6.0

2 个解决方案

#1


2  

Though I don't know whether or not you're getting an exception at the moment, this is almost assuredly a permissions issue. IIS is going to send the credentials the Application Pool is running under when trying to create the folders. This is generally defaulted to NETWORK SERVICE.

雖然我不知道你目前是否收到例外,但這幾乎肯定是一個權限問題。在嘗試創建文件夾時,IIS將發送應用程序池正在運行的憑據。這通常默認為NETWORK SERVICE。

Have a look at the user the Application Pool is running under, then check out the permissions of the root folder, and ensure that user has Write access.

查看運行應用程序池的用戶,然后檢查根文件夾的權限,並確保用戶具有寫訪問權限。

Once the Application Pool user has permissions -you're good.

一旦應用程序池用戶擁有權限 - 你就是好人。

#2


0  

This will be a permissions issue, when you run the program using visual studio the application runs with your own credentials, however when the site is run in IIS it will run with whichever account is assigned to the application pool and by default this will be a local account on the machine which won't have any permissions on a remote server.

這將是一個權限問題,當您使用visual studio運行程序時,應用程序使用您自己的憑據運行,但是當該站點在IIS中運行時,它將使用分配給應用程序池的任何帳戶運行,並且默認情況下這將是機器上的本地帳戶,對遠程服務器沒有任何權限。

If you use impersonation you can setup an account which has the relevant permissions on the remote server and your application will have access to those remote folders/files.

如果您使用模擬,則可以設置一個在遠程服務器上具有相關權限的帳戶,您的應用程序將可以訪問這些遠程文件夾/文件。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/06/13/bfe7d7e2cef205dc00d7a5456b882ea6.html



 
  © 2014-2022 ITdaan.com 联系我们: