【問題】
在WLW中拖入本地圖片文件,然后調試過程中,選中對應圖片,看到獲得的對應的html源碼中,圖片地址是這樣的:
href="file:///C:/Users/CLi/AppData/Local/Temp/WindowsLiveWriter1627300719/supfiles52F410/wangdan-se-436963[2].jpg">
即使一個file加上一個冒號,再跟着三個斜杠的形式。
想要搞懂這種寫法的確切含義。
【解決過程】
1.搜“C# file colon three slash”找到這里:
http://bytes.com/topic/html-css/answers/154018-href-file-c-temp-target-_blank-c-temp-does-not-work-ie-anymore
提到了說是file protocol,所以猜測估計是和http和ftp等價的某種file協議。
2.那就是和C#無關,那就去搜“file protocol colon three slash”,然后找到:
http://www.urbandictionary.com/define.php?term=protocol%20section&defid=4118180
解釋說:
The file (colon) // (slashes required) URL is good for accessing individual files. It has the ability to access the machine you’re using, or one you’re connected to, just by typing the path, in which you do file (colon) // then another slash (making 3), then in which you type a folder name, another slash, a folder inside that, and so on, until the file name. Hit enter, and the file is accessed.
總之,就是用file:///加上對應文件的地址,打開對應的本地電腦(或者你所連接到的電腦的 ->估計指的是像windows中映射出來其他網絡鄰居中某個計算機為某個網盤的情況)中對應的文件。
3.試了試,在Win7的資源管理器中,直接輸入:
file:///C:/Users/CLi/AppData/Local/Temp/WindowsLiveWriter1627300719/supfiles52F410/wangdan-se-436963[2].jpg
是可以打開此圖片的。
【總結】
用file:///+文件的地址,其實就等價於文件的地址,
即:
file:///C:/Users/CLi/AppData/Local/Temp/WindowsLiveWriter1627300719/supfiles52F410/wangdan-se-436963[2].jpg
其實就等價於;
C:/Users/CLi/AppData/Local/Temp/WindowsLiveWriter1627300719/supfiles52F410/wangdan-se-436963[2].jpg
使得(此處Html源碼中所允許的地址,對應的WLW程序)可以訪問對應的文件而已。