2015-12-24 230 views
1


首先,我會說我挖了一半的互聯網爲這個和無處不在,我發現:「不,你不能它是網絡瀏覽器的安全性」。
我需要這個ASP的Intranet網頁。 NET MVC5 + C#。 應允許用戶在某種對話框中選擇文件或文件夾。然後選擇時,我想找回所選項目的路徑[也是網絡驅動器上的文件或文件夾。但是,而不是映射路徑像z:\ ...我更喜歡\\ Server50 \文件夾\ folder2 \ file.ext]
然後,我想發送此路徑到SQL DB的一些操作。 (這很容易)

這就是我想要完整的UNC路徑的原因。沒有要上傳的文件。

任何人都可以給我一些線索在哪裏尋找或開始?C#MVC獲取完整文件路徑

+0

檢查https://msdn.microsoft.com/en-us/library/system.io.path.getfullpath(v=vs.110).aspx –

+1

正如您已經在互聯網的一半上發現的那樣,爲了安全原因,你試圖實現的是不可能的。您可以在客戶端計算機上使用專有的ActiveX安裝組件來實現此目的。 –

+1

我不相信「不可能」的情況。如果有這麼多人問這個問題,那就必須有一個解決方案。我將搜索ActiveX解決方案。 – Lukasz

回答

0

所以它現在是可能的內聯網用途]
我用MVC + Silverlight的+證書在客戶端

添加Silverlight項目到Visual Studio解決方案:在MVC應用程序項目 -
right-click>Properties
SilverLight Application tab - >Add...
-check Copy to configuration specific folder
-uncheck Add a test page...
-ch的eck enable Silverlight debugging

銀光:在.xaml.cs主頁:

public MainPage() 
    { 
     InitializeComponent(); 
     LayoutRoot.Drop += new DragEventHandler(drop);//important to add 
    } 

    private void drop(object sender, DragEventArgs e) 
    { 
     if (e.Data!=null) 
     { 
      FileInfo[] files = e.Data.GetData(DataFormats.FileDrop) as FileInfo[]; 
      foreach(var item in files) 
      { 
       //fullpath in: item.Fullname property 
       } 
     } 
    } 


在XAML主網頁設計

<Grid x:Name="LayoutRoot" Background="#FFBF6666" AllowDrop="true"> 
    <Button x:Name="button" Content="Button" HorizontalAlignment="Left"  Margin="72,38,0,0" VerticalAlignment="Top" Width="75" Click="button_Click"/> 
</Grid> 


right-click Silverlight的項目 - >Properties
Signing tab->檢查Sign the xap file - >在MVC應用程序Create the test certificate


查看設置:

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> 
<div id="silverlightControlHost"> 
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="1000" height="800"> 
    <param name="source" value="/ClientBin/System.xap" /> 
    <param name="onError" value="onSilverlightError" /> 
    <param name="background" value="white" /> 
    <param name="minRuntimeVersion" value="5.0.61118.0" /> 
    <param name="autoUpgrade" value="true" /> 
    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="text-decoration:none"> 
     <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none" /> 
    </a> 
</object> 
    </div> 
</asp:Content> 


重建兩個項目
部署到生產服務器
...trusted root authorities

安裝在客戶端創建的證書現在是工作;]

我看到一些人將.xap,.xaml擴展名添加到web.config中,但對我來說卻沒有幫助。