PDA

View Full Version : برنامه asp.net كار با دايركتوري در سرور linux



majidqsk
دوشنبه 11 بهمن 1389, 13:43 عصر
با سلام

من يه سرور لينوكسي دارم ميخوام برنامه اي با asp.net بنويسم كه بره اطلاعات يه سري فولدر و اسامي فايل هاي توشون رو برام از روي سرور برگردونه.( مثل كار با كلاس directory, directory info) (اين فولدرها از طريق پورتال بعد از وارد شدن به پنل مدير در دسترس هستند).
من پسورد كاربر root رو دارم .ftp هم فعاله.
ممنون ميشم اگر براي نوشتن برنامه براي انجام اين كار راهنماييم كنين.

من براي تست ftp چنين كدي نوشتم كه اين error رو ميده:


Unable to connect to the remote server




Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.


Exception Details:
System.Net.WebException: Unable to connect to the remote server


------


protected void Button1_Click(object sender, EventArgs e)
{
//getdfiles();

ftpfile(@"/opt/lampp/htdocs/.....", @"D:\upload.xml");
}

public void ftpfile(string ftpfilepath, string inputfilepath)
{
string ftphost = "**********";


string ftpfullpath = "ftp://" + ftphost + ftpfilepath;
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
ftp.Credentials = new NetworkCredential("root", "My23SamServth");
//userid and password for the ftp server to given
ftp.Proxy = null;
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.ListDirectory;

FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
--------------------------


اين كد رو كه استفاده ميكنم ميگه كه به اين فولدر دسترسي نداري
----

string mainDir = @"\\94******\~\opt\lampp\htdocs\files";
string journalDir;
int c=10;

journalDir = mainDir;
string[] d = Directory.GetFiles(journalDir);
foreach (string dir in d)
{
TextBox1.Text = dir;
}



-----------------


Access to the path '\\94.****\~\opt\lampp\htdocs\files' is denied.


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path '\\94********\~\opt\lampp\htdocs\files' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access
-----------------------.

aminghaderi
دوشنبه 11 بهمن 1389, 17:38 عصر
آخه لینوکس کجا و asp.net کجا....:گیج:
اصلا asp.net روی لینوس کار نمی کنه....
باید برید سرور ویندوز بگیرید.

موفق باشی.