الشبكة العربية لمطوري الألعاب

مبتدئ  إياد طرابلسي مشاركة 1

When we decide to upload our web for the first time we encounter troubles in specifying the phisical addresses of all our editable files which are created automatically by the website itself...

For instance "SaveAs method" which is used by the FileUpload tool, it asks for the root address "unqualified to hold an absolute address" so when we upload the website, All the files which were done on the local machine could be missed on the server

On the other side... we have another choice to use for reading & writing files which are "StreamWriter & StreamReader". we could pass them direct address of the type "FileName" . When we do they suppose directly a default address like this one for instance "D:\Program Files\Microsoft Visual Studio 8\Common7\IDE"

And in both ways when we use like this statment as an address "\\pics\\FileName" it supposes a default directory like "D:\\" for instance and launch the address from there, I mean that it looks for "pics" directory to find the file inside

Hope everibody contribute with his experince in "The absolute directory & the root directory" to be completely obvious...

خبير مدير وسام البهنسي مشاركة 2

الطريقة المثلى للحصول على الدليل الحقيقي على المخدم والذي يوافق الـ URL المطلوب هي باستخدام الإجراء: Server.MapPath

كمثال، النداء التالي:
String absPath = Server.MapPath("images/title.jpg");
// absPath now can be "C:\wwwRoot\trabulsico\images\title.jpg"

الآن يمكنك تمرير الدليل الجديد لوحدات فتح الملفات المحلية كـ StreamReader و StreamWriter. فقط نقطة أخيرة قد تواجهك، هي السماحيات. يجب أن تعطي سماحيات كافية للمستخدم ASPNET على المخدم كي يستطيع القراءة والكتابة بشكل مباشر من الدليل المطلوب. تأكد من السماح فقط لمستخدم ASPNET لأن هذا قد يعرض الموقع لمخاطر جمة.

وسام البهنسي
مبرمج في إنفيديا وإنفريمز