应用属性资源 [英] Application Properties Resources

查看:81
本文介绍了应用属性资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。



我正在尝试访问vs 2010 windows窗体中的properties.resources以返回一个特定文件,但是没有指定地址如下所示



我的代码是这样的:



  public 流文件(字符串资源,字符串扩展名)
{
switch (扩展名)
{
案例 htm
if ( ( String .Compare(resource, index)!= 0 )&&( String .Compare(resource, login)!= 0 ))
{
if (!Authenticate()) return null ;
}
WebOperationContext.Current.OutgoingResponse.ContentType = text / html ;
break ;
case js
WebOperationContext.Current.OutgoingResponse.ContentType = text / javascript;
break ;
case css
WebOperationContext.Current.OutgoingResponse.ContentType = text / css;
break ;
case png
WebOperationContext.Current.OutgoingResponse.ContentType = image / png;
break ;
case ico
WebOperationContext.Current.OutgoingResponse.ContentType = image / x-icon;
break ;
默认
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.UnsupportedMediaType;
return new MemoryStream(Encoding.ASCII.GetBytes( 不支持文件类型), false );
}
string fileName = String .Format( @ C:\ Users \ Lopez \ Documents \ visualual studio 2010 \Projects \ Hello &\\ Hello &\\ Resources \ {0}。{1},资源,扩展名);
return new FileStream(fileName,FileMode.Open);
}





我的问题是如何更改此部分

 string fileName = String.Format(@C:\Users\Lopez \Documents\visual studio 2010 \Projects\Hello \Hello \Resources \ {0}。{1},资源,扩展); 





类似



 Hello.Properties.Resources.state 





thk

解决方案

i没有那个文件,我正在一个Windows窗体中工作,实现了一个Web服务器(本地)。 htm文件显示在表单中的webbrowser组件中。

我的ideia是在切换案例之后,以某种方式调用我想要的文件而不定义特定的地址(我的机器)。关键是要在其他计算机上运行该应用程序,因为我无法拥有这条路径

 C:\ Users \ Lopez \ Disocuments \ visual studio 2010 \ Projects\Hello\Hello\Resources\ 


Hi.

i'm trying to access the properties.resources in vs 2010 windows form to return a specif file, but whithout specifing the address as shown bellow

my code is this:

public Stream Files(string resource, string extension)
       {
           switch (extension)
           {
              case "htm":
                   if ((String.Compare(resource, "index") != 0) && (String.Compare(resource, "login") != 0))
                   {
                       if (!Authenticate()) return null;
                   }
                   WebOperationContext.Current.OutgoingResponse.ContentType = "text/html";
                   break;
               case "js":
                   WebOperationContext.Current.OutgoingResponse.ContentType = "text/javascript";
                   break;
               case "css":
                   WebOperationContext.Current.OutgoingResponse.ContentType = "text/css";
                   break;
               case "png":
                   WebOperationContext.Current.OutgoingResponse.ContentType = "image/png";
                   break;
               case "ico":
                   WebOperationContext.Current.OutgoingResponse.ContentType = "image/x-icon";
                   break;
               default:
                   WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.UnsupportedMediaType;
                   return new MemoryStream(Encoding.ASCII.GetBytes("File type not supported"), false);
           }
           string fileName = String.Format(@"C:\Users\Lopez\Documents\visual studio 2010\Projects\Hello\Hello\Resources\{0}.{1}", resource, extension);
           return new FileStream(fileName, FileMode.Open);
       }



My problem is how to change this part

string fileName = String.Format(@"C:\Users\Lopez\Documents\visual studio 2010\Projects\Hello\Hello\Resources\{0}.{1}", resource, extension);



in something like

Hello.Properties.Resources.state



thk

解决方案

i don't have that file, i'm working in a windows form that as implemented a web server (local). the htm files are being showed in a webbrowser component in the form.
my ideia was after the switch case, somehow call the file that i want without defining a specific address (my machine). the point is to run the application in other computers, for that i cannot have this path

C:\Users\Lopez\Documents\visual studio 2010\Projects\Hello\Hello\Resources\


这篇关于应用属性资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆