문제

I want to completely understand how to use relative and absolute url address in static and dynamic files.

~  : 
/  :
.. : in a relative URL indicates the parent directory
 . : refers to the current directory
 / : always replaces the entire pathname of the base URL
// : always replaces everything from the hostname onwards

This example is easy when you are working without virtual directory. But i am working on virtual directory.

Relative URI          Absolute URI
about.html            http://WebReference.com/html/about.html
tutorial1/            http://WebReference.com/html/tutorial1/
tutorial1/2.html      http://WebReference.com/html/tutorial1/2.html
/                     http://WebReference.com/
//www.internet.com/   http://www.internet.com/
/experts/             http://WebReference.com/experts/
../                   http://WebReference.com/
../experts/           http://WebReference.com/experts/
../../../             http://WebReference.com/
./                    http://WebReference.com/html/
./about.html          http://WebReference.com/html/about.html

I want to simulate a site below, like my project which is working on virtual directory.

These are my aspx and ascx folder

http://hostAddress:port/virtualDirectory/MainSite/ASPX/default.aspx
http://hostAddress:port/virtualDirectory/MainSite/ASCX/UserCtrl/login.ascx

http://hostAddress:port/virtualDirectory/AdminSite/ASPX/ASCX/default.aspx

These are my JS Files(which will be use both with the aspx and ascx files):

http://hostAddress:port/virtualDirectory/MainSite/JavascriptFolder/jsFile.js
http://hostAddress:port/virtualDirectory/AdminSite/JavascriptFolder/jsFile.js

this is my static web page address(I want to show some pictures and run inside some js functions):

http://hostAddress:port/virtualDirectory/HTMLFiles/page.html

this is my image folder

http://hostAddress:port/virtualDirectory/Images/PNG/arrow.png
http://hostAddress:port/virtualDirectory/Images/GIF/arrow.png

if i want to write and image file's link in my ASPX file i should write

aspxImgCtrl.ImageUrl = Server.MapPath("~")+"/Images/GIF/arrow.png";

But if i want to write the path hard coded or from javascript file, what kind of url address it should be?

도움이 되었습니까?

해결책

귀하의 접근 방식은 파울입니다.파일을 순차적으로 처리하십시오.어쨌든 그것을 작성해야합니다 :

(읽기를위한 파일 열기, 쓰기를위한 새 파일 열기)

  1. readline -> 문자열 변수
  2. readline을 예약하면 다음 두 줄을 아무 것도하지 않고 읽으십시오.
  3. 가 아니라면 2) 그런 다음 라인을 새 파일에 씁니다.
  4. 새 파일을 플러시하고 둘 다를 닫습니다.
  5. 이전 파일을 삭제하고 새 이름을 이전 이름으로 이동하십시오.

    완료되었습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top