这应该是一项简单的任务,但我似乎无法找到解决方案.
我有一个基本字符串作为查询字符串参数传递,如下所示:This+is+a+message+with+spaces.我想使用JavaScript解码该参数This is a message with spaces,但我似乎无法解码它.
我试过decodeURI('This+is+a+message+with+spaces')但结果仍然包含+迹象.
我一直在玩HTML5 Canvas,我注意到了一些我无法在网上找到解决方案的东西.这是我正在玩的简单代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<canvas id="canvas" style="border: 1px solid;" width="200" height="200"></canvas>
<br />
<button id="draw">draw</button>
<button id="clear">clear</button>
</body>
</html>
<script type="text/javascript">
(function () {
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
$("#draw").bind("click", function () {
for (var i = 0; i < 200; i++) {
context.moveTo(0, i);
context.lineTo(100, 100);
context.stroke();
}
});
$("#clear").bind("click", function () {
context.clearRect(0, 0, 200, 200);
});
} ());
</script>
Run Code Online (Sandbox Code Playgroud)
每次我按下绘图时,它完成的速度似乎都呈指数减速.谁能知道为什么会这样? …
我正在编写一个获取所有目录和子目录的程序.我正在使用以下代码:
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{
string[] directories = Directory.GetDirectories(drive.Name, "*", SearchOption.AllDirectories);
}
Run Code Online (Sandbox Code Playgroud)
但我得到一个例外,说"访问路径'C:\ Documents and Settings \'被拒绝."
我正在使用Windows 7,我在资源管理器中看不到C:\ Documents and Settings \文件夹.我启用了"显示隐藏文件和文件夹",甚至尝试直接键入路径,但它出现以下错误:"C:\ Documents and Settings无法访问.访问被拒绝."
为什么要Directory.GetDirectories()拉一个似乎不存在的目录?