小编a12*_*773的帖子

无法使用Server.MapPath

我必须做些什么来做Server.MapPath工作?
我有using System.Web;

还有什么?当我输入时Server,没有快速结果选项(智能)Server.

有帮助吗?

c# intellisense server.mappath visual-studio

106
推荐指数
3
解决办法
21万
查看次数

App.Config更改值

这是我的App.Config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="lang" value="English"/>
  </appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

使用此代码,我进行了更改

lang = "Russian";
private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
     System.Configuration.ConfigurationManager.AppSettings.Set("lang", lang);
}
Run Code Online (Sandbox Code Playgroud)

但它没有改变.我做错了什么?

c# app-config

40
推荐指数
4
解决办法
15万
查看次数

在引导程序中更改图标栏(☰)颜色

我想改变☰颜色.

HTML:

<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#menu">
  <span class="sr-only">Toggle menu navigation</span>
  <span class="icon-bar"></span>
  <span class="icon-bar"></span>
  <span class="icon-bar"></span>
</button>
Run Code Online (Sandbox Code Playgroud)

我尝试了各种各样的东西(看起来吼叫)但没有任何作用

CSS:

.icon-bar {
  color: black;
  border-color: black;
  background-color: black;
}
Run Code Online (Sandbox Code Playgroud)

css css-specificity twitter-bootstrap

37
推荐指数
2
解决办法
11万
查看次数

从资源加载图像

我想加载这样的图像:

void info(string channel)
{
    //Something like that
    channelPic.Image = Properties.Resources.+channel
}
Run Code Online (Sandbox Code Playgroud)

因为我不想这样做

void info(string channel)
{
    switch(channel)
    {
        case "chan1":
            channelPic.Image = Properties.Resources.chan1;
            break;
        case "chan2":
            channelPic.Image = Properties.Resources.chan2;
            break;
    }
}
Run Code Online (Sandbox Code Playgroud)

这样的事情可能吗?

c# resources image picturebox

29
推荐指数
3
解决办法
13万
查看次数

Catch vs Catch(例外e)和Throw vs Throw e

这两个代码示例是否相同?Catch and Catch(Exception e)具有相同的输出,如果我写ThrowThrow e,结果也是相同的.

主要:

try
{
    A();
    //B();
}
catch (Exception e)
{
    Console.WriteLine("{0} exception caught.", e);
}
Run Code Online (Sandbox Code Playgroud)

代码1:

static void A()
{
    try
    {
        int value = 1 / int.Parse("0");
    }
    catch (Exception e)
    {
        throw e;
    }
}
Run Code Online (Sandbox Code Playgroud)

代码2:

static void A()
{
    // Rethrow syntax.
    try
    {
        int value = 1 / int.Parse("0");
    }
    catch
    {
        throw;
    }
}
Run Code Online (Sandbox Code Playgroud)

c# try-catch

24
推荐指数
2
解决办法
6万
查看次数

实现快速排序算法

我在本书中找到了快速排序算法

这是算法

QUICKSORT (A, p, r)
if p < r
    q = PARTITION(A, p, r)
    QUICKSORT(A, p, q-1)
    QUICKSORT(A, q+1, r)

PARTITION(A, p, r)
x=A[r]
i=p-1
for j = p to r - 1
  if A <= x
     i = i + 1
     exchange A[i] with A[j]
exchange A[i+1] with A[r]
return i + 1
Run Code Online (Sandbox Code Playgroud)

我做了这个c#代码:

private void quicksort(int[] input, int low, int high)
{
    int pivot_loc = 0;

    if (low < high)
        pivot_loc = partition(input, low, high);
    quicksort(input, low, …
Run Code Online (Sandbox Code Playgroud)

c# algorithm quicksort

20
推荐指数
2
解决办法
5万
查看次数

使用C#Console Application获取应用程序目录?

我在谷歌上找到了一些东西,但它不适用于C#控制台应用程序

我找到了什么:

string appPath = Path.GetDirectoryName(Application.ExecutablePath);
Run Code Online (Sandbox Code Playgroud)

如何使用c#控制台应用程序获取应用程序目录?

c# directory console

13
推荐指数
3
解决办法
4万
查看次数

HTTPError:HTTP错误403:禁止

我制作一个python脚本供个人使用,但它不适用于维基百科......

这项工作:

import urllib2, sys
from bs4 import BeautifulSoup

site = "http://youtube.com"
page = urllib2.urlopen(site)
soup = BeautifulSoup(page)
print soup
Run Code Online (Sandbox Code Playgroud)

这不起作用:

import urllib2, sys
from bs4 import BeautifulSoup

site= "http://en.wikipedia.org/wiki/StackOverflow"
page = urllib2.urlopen(site)
soup = BeautifulSoup(page)
print soup
Run Code Online (Sandbox Code Playgroud)

这是错误:

Traceback (most recent call last):
  File "C:\Python27\wiki.py", line 5, in <module>
    page = urllib2.urlopen(site)
  File "C:\Python27\lib\urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Python27\lib\urllib2.py", line 406, in open
    response = meth(req, response)
  File "C:\Python27\lib\urllib2.py", line 519, in http_response
    'http', …
Run Code Online (Sandbox Code Playgroud)

python beautifulsoup python-2.7

13
推荐指数
1
解决办法
3万
查看次数

填写类型文本的输入并使用python按提交

我有这个HTML:

<input type="text" class="txtSearch">
<input type="submit" value="Search" class="sbtSearch">
Run Code Online (Sandbox Code Playgroud)

我需要的是在文本字段中写入,然后单击使用python提交.输入标记不在Form中.我怎么能这样做?

html python beautifulsoup python-2.7

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

如何将cookie传递给HtmlAgilityPack或WebClient?

我使用此代码登录:

CookieCollection cookies = new CookieCollection();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("example.com");
request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(cookies);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
cookies = response.Cookies;

string getUrl = "example.com";
string postData = String.Format("my parameters");
HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create(getUrl);
getRequest.CookieContainer = new CookieContainer();
getRequest.CookieContainer.Add(cookies);
getRequest.Method = WebRequestMethods.Http.Post;
getRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0";
getRequest.AllowWriteStreamBuffering = true;
getRequest.ProtocolVersion = HttpVersion.Version11;
getRequest.AllowAutoRedirect = true;
getRequest.ContentType = "application/x-www-form-urlencoded";

byte[] byteArray = Encoding.ASCII.GetBytes(postData);
getRequest.ContentLength = byteArray.Length;
Stream newStream = getRequest.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);
newStream.Close(); …
Run Code Online (Sandbox Code Playgroud)

c# cookies webclient httpwebrequest html-agility-pack

10
推荐指数
1
解决办法
1万
查看次数