小编Ron*_*man的帖子

如何通过文件名[c#]获取文件的路径

首先,我知道有很多问题看起来像这个,但我无法真正得到我的问题的答案.

所以一般来说,我正在运行一个程序,需要获得另一个Visual Studio项目解决方案文件的解决方案的路径,我只有文件本身的名称.

例如,我的程序在后台运行,目前正在编写一个visual studio项目,我需要获得该项目解决方案的路径.该项目尚未编译,这是一个刚刚创建的新项目.例如MyProject.sln,文件和我正在寻找的目录是C:\Users\MyUser\Documents\Visual Studio 2015\Projects\MyProject\MyProject.sln.当然,项目可以在计算机上的任何位置,如不同的驱动器,或者不在visual studio文件夹中.

我尝试使用诸如Path.GetDirectoryName(filename)返回空字符串的方法,或者Path.GetFullPath(path)返回错误路径(搜索路径的程序之一)或者Directory.GetDirectories(path,searchPattern)使用SearchOptions返回的方法,然后我SearchOption.AllDirectories在许多文件上获得授权错误.

我真的迷失在这里,希望有人能帮忙!

c# directory path visual-studio visual-studio-2015

5
推荐指数
1
解决办法
253
查看次数

尝试获取文件URL的Firebase存储访问时出现错误400

我正在尝试使用ionic和firebase平台,但遇到了问题。

因此,我在尝试访问的存储中有一个图像,我尝试使用getDownloadURL()方法,但始终收到错误400,“无效的http方法/ URL对”。我找不到任何解决方案。尝试使用getMetadata()时出现相同的错误。

firebase已初始化,目前一切正常,身份验证,数据库读取等等。除了这个错误...

我在服务中有以下代码。

// Get a reference to the storage service, which is used to create references in your storage bucket
var storage = firebase.storage();

// Create a storage reference from our storage service
var storageRef = storage.ref();

// Create a child reference
var imagesRef = storageRef.child('images');
// imagesRef now points to 'images'

return {
    getImgRef: function (imgName) {
        var imgRef = imagesRef.child('Tanker.ico')
        imgRef.getDownloadURL().then(function (url) {
            return url
        }).catch(function(error) {
            switch (error.code) {
                case 'storage/object_not_found':
                    // File doesn't …
Run Code Online (Sandbox Code Playgroud)

javascript firebase ionic-framework firebase-storage

3
推荐指数
2
解决办法
2216
查看次数