質問

静的ファイルと動的ファイルで相対的および絶対URLアドレスを使用する方法を完全に理解したいと思います。

~  : 
/  :
.. : 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

この例は、仮想ディレクトリなしで作業している場合に簡単です。しかし、私は仮想ディレクトリに取り組んでいます。

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

仮想ディレクトリで動作しているプロジェクトのように、以下のサイトをシミュレートしたいと思います。

これらは私のASPXフォルダーとASCXフォルダーです

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

これらは私のJSファイルです(ASPXファイルとASCXファイルの両方で使用されます):

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

これは私の静的なWebページアドレスです(いくつかの写真を見せて、いくつかのJS関数内で実行したい):

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

これが私の画像フォルダーです

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

ASPXファイルにファイルのリンクを書き込み、画像ファイルのリンクを書きたい場合

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

しかし、ハードコード化されたパスまたはJavaScriptファイルからPathを書きたい場合、どのようなURLアドレスがあるはずですか?

役に立ちましたか?

解決

あなたのアプローチはファウルです。ファイルを順番に処理してみてください。とにかく書く必要があることを忘れないでください。

(読み取り用のオープンファイル、書き込み用の新しいファイルを開く)

  1. readline - >文字列変数
  2. Readlineがあなたの予約の場合は、何もせずに次の2行を読んでください。
  3. 2)2)次に新しいファイルに行を書きます。
  4. 新しいファイルをフラッシュして両方を閉じます。
  5. 古いファイルを削除して、新しい名前に新しい名前に移動します。

    完了

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top