C#MVC获取完整文件路径

时间:2015-12-24 18:48:01

标签: javascript c# model-view-controller activex


首先,我要说的是,为了这个以及我发现的任何地方,我挖了一半的互联网:"否你不能是网络浏览器安全"。
我需要这个用于ASP的Intranet网页。 NET MVC5 + C#。 应允许用户在某种对话框中选择文件或文件夹。然后,当我选择时,我想回到所选项目的路径[也是网络驱动器上的文件或文件夹。但是,而不是像z:\ ...这样的映射路径,我更喜欢\\ Server50 \ folder \ folder2 \ file.ext]
然后我想将此路径发送到SQL DB以执行某些操作。 (那很容易的部分)

这就是我想要完整的UNC路径的原因。没有要上传的文件。

谁能给我一些线索在哪里寻找或开始?

1 个答案:

答案 0 :(得分:0)

因此现在可以用于内部网目的;]
我在客户端使用了MVC + Silverlight +证书
将Silverlight项目添加到Visual Studio解决方案:
MVC app Project上的right-click - > Properties
SilverLight Application tab - > Add...
- 检查Copy to configuration specific folder
-uncheck Add a test page...
- 检查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项目 - &gt; Properties
Signing标签 - &gt;检查Sign the xap file - &gt; Create the test certificate


在MVC app中查看设置:

<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

中的客户端安装创建的证书

现在正在运作;]

我看到有些人在web.config中添加了.xap,.xaml扩展名,但对我来说却没有帮助。

相关问题