我正在使用.NET 3.5,尝试使用以下命令递归删除目录:
Directory.Delete(myPath, true);
Run Code Online (Sandbox Code Playgroud)
我的理解是,如果文件正在使用或存在权限问题,这应该抛出,否则它应该删除目录及其所有内容.
但是,我偶尔会得到这个:
System.IO.IOException: The directory is not empty.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive)
...
Run Code Online (Sandbox Code Playgroud)
我对这种方法有时会抛出并不感到惊讶,但是当递归为真时,我很惊讶地得到这条特殊的信息.(我知道目录不是空的.)
有没有理由我看到这个而不是AccessViolationException?
我想删除包含数千个文件和文件夹的文件夹.如果我使用Windows资源管理器删除文件夹,则可能需要10-15分钟(并非总是如此,但经常).Windows中有更快的方法来删除文件夹吗?
其他详情:
我有一个int arr[5]传递给函数的数组fillarr(int arr[]):
int fillarr(int arr[])
{
for(...);
return arr;
}
Run Code Online (Sandbox Code Playgroud)
<html>
<style type="text/css">
.table { display: table;}
.tablerow { display: table-row; border:1px solid black;}
.tablecell { display: table-cell; }
</style>
<div class="table">
<div class="tablerow">
<div class="tablecell">Hello</div>
<div class="tablecell">world</div>
</div>
<div class="tablerow">
<div class="tablecell">foo</div>
<div class="tablecell">bar</div>
</div>
</div>
</html>
Run Code Online (Sandbox Code Playgroud)
根据我的理解,应该在我通过tablerow类指定的每一行上画一个黑色边框.但边框不会出现.
我想改变一行的高度.如果我用'px'指定它 - 它工作.但是,如果我给它一个% - 不会工作.我试过以下
.tablerow {
display: table-row;
border:1px solid black;
position: relative; //not affecting anything and the border disappears!!
//position: absolute; // if this is set,the rows overlaps and the border works
height: 40%; // works only if specified …Run Code Online (Sandbox Code Playgroud) 有没有办法在Jasmine expect()失败时打印自定义错误消息?
作为一个例子,对于端到端测试我有一个网页数组,我使用一个测试来转到每个URL并断言每个页面上存在一个元素.我知道我可以把每个人都expect()放到一个单独的测试中,但我宁愿遍历数组并在失败时记录页面URL.
嗨我想通过标量值来(乘法,加法等)矢量,例如myv1 * 3,我知道我可以用forloop做一个函数,但有没有办法用STL函数做到这一点?像{Algorithm.h :: transform function}这样的东西?
如果我的网址是http://www.something.com/foo/bar/index.html?color=yellow&animal=rat,似乎:
$location.path() 将返回 foo/bar/index.html$location.absUrl() 将返回 http://www.something.com/foo/bar/index.html?color=yellow&animal=rat$location.url() 将返回 foo/bar/index.html?color=yellow&animal=rat有什么功能会回来http://www.something.com/foo/bar/index.html吗?
或者我是否必须使用protcol,host,port等函数构建自己(或者自己删除查询参数)?
我来自C++背景,我希望有一个矩阵
ArrayList<arrayList<E>> javamatrix
Run Code Online (Sandbox Code Playgroud)
在C++中我会这样做
std::vector<std::vector<T> > cppmatrix;
std::vector<T>vcol(cols);
cppmatrix.resize(rows,vcol);
Run Code Online (Sandbox Code Playgroud)
我似乎无法为此任务找到内置resize()函数ArrayLists,所以我应该使用另一个集合吗?除了使用for循环外,没办法做到这一点javamatrix.add()吗?
PS我想在构造函数中初始化它的大小,因为在编辑元素或添加或删除之前可能会查询该大小.
我四处寻找,我无法让它发挥作用.我想我只是不知道正确的语法,或者只是不完全掌握上下文.
我有一个BombDrop脚本,它包含一个public int.我得到了这个与public static一起工作,但有人说这是一个非常糟糕的编程习惯,我应该学习封装.这是我写的:
BombDrop脚本:
<!-- language: c# -->
public class BombDrop : MonoBehaviour {
public GameObject BombPrefab;
//Bombs that the player can drop
public int maxBombs = 1;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Space)){
if(maxBombs > 0){
DropBomb();
//telling in console current bombs
Debug.Log("maxBombs = " + maxBombs);
}
}
}
void DropBomb(){
// remove one bomb from the current maxBombs
maxBombs -= 1;
// spawn bomb prefab
Vector2 pos = transform.position; …Run Code Online (Sandbox Code Playgroud) c# ×3
c++ ×2
io ×2
.net ×1
angularjs ×1
arraylist ×1
arrays ×1
css ×1
css-tables ×1
element ×1
exception ×1
fluid-layout ×1
function ×1
jasmine ×1
java ×1
javascript ×1
matrix ×1
operation ×1
pointers ×1
protractor ×1
reference ×1
return ×1
stl ×1
testing ×1
url ×1
vector ×1
windows ×1
windows-xp ×1