2015-12-24 232 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中,但对我来说却没有帮助。