ดาวน์โหลดหน้า aspx

HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost:51659/jobpoint3.0/Default4.aspx"); ลูกค้า WebClient = WebClient ใหม่ (); ชื่อไฟล์สตริง = @"C:/Users/leema/" + txtsave.Text;
client.DownloadFile("http://localhost:51659/jobpoint3.0/Default4.aspx", @"C:/Users/leema/"+ txtsave.Text); //HttpResponseWriteFile(ชื่อไฟล์); HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); myHttpWebResponse.ปิด();

ที่นี่ฉันได้รับเส้นทางในเครื่อง .. ฉันจะรับเส้นทางเดสก์ท็อปของผู้ใช้สำหรับผู้ใช้ใด ๆ ได้อย่างไร ??


person Leema    schedule 25.08.2010    source แหล่งที่มา
comment
ขอโทษ ฉันรู้วิธีทำ คุณบอกฉันได้ไหม?   -  person Leema    schedule 25.08.2010


คำตอบ (1)


รหัสคือ

Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)

ดังนั้นบรรทัดที่ 3 ของคุณจะถูกแก้ไขเป็น

 string filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), txtsave.Text);
person ajay_whiz    schedule 25.08.2010
comment
แต่มันบอกว่าการเข้าถึงเส้นทางถูกปฏิเสธหลังจากเผยแพร่แล้ว - person Leema; 25.08.2010
comment
@Leema พยายามแก้ไข / พิมพ์ชื่อไฟล์เพื่อดูตำแหน่งที่ถูกต้อง ว่าแต่ OS ไหนที่คุณรันแอพพลิเคชั่นนี้ครับ? - person ajay_whiz; 25.08.2010