备注:由于垃圾邮件防范机制,我被迫将Uris的开头从ftp://替换为ftp.
我有以下问题.我必须使用C#ftp方法上传文件,然后重命名它.容易,对吗?:)
好吧,假设我的ftp主机是这样的:
ftp.contoso.com
登录后,当前目录设置为:
用户/名称
所以,我想要实现的是登录,将文件作为file.ext.tmp上传到当前目录,上传成功后,将文件重命名为file.ext
正如我猜想的那样,整个难题是为FtpWebRequest正确设置请求Uri.
MSDN声明:
URI可以是相对的或绝对的.如果URI的格式为" ftp://contoso.com/%2fpath"(%2f是转义'/'),那么URI是绝对的,当前目录是/ path.但是,如果URI的格式为" ftp://contoso.com/path ",则首先.NET Framework登录到FTP服务器(使用Credentials属性设置的用户名和密码),然后是当前目录设置为UserLoginDirectory/path.
好的,所以我上传了带有以下URI的文件:
ftp.contoso.com/file.ext.tmp
好的,文件落在我想要的位置:在目录"users/name"中
现在,我想重命名该文件,因此我使用以下Uri创建Web请求:
ftp.contoso.com/file.ext.tmp
并指定重命名为参数:
file.ext
这给了我550错误:找不到文件,没有权限等.
我在Microsoft网络监视器中跟踪了它,它给了我:
命令:RNFR,从
CommandParameter 重命名:/file.ext.tmp
Ftp:响应端口53724,'550 File /file.ext.tmp not found'
好像是在根目录中查找文件 - 而不是在当前目录中.
我使用Total Commander手动重命名了文件,唯一的区别是CommandParameter没有第一个斜杠:
CommandParameter:file.ext.tmp
我可以通过提供以下绝对URI来成功重命名该文件:
ftp.contoso.com/%2fusers/%2fname/file.ext.tmp
但我不喜欢这种方法,因为我必须知道当前用户目录的名称.它可以通过使用WebRequestMethods.Ftp.PrintWorkingDirectory来完成,但它增加了额外的复杂性(调用此方法来检索目录名,然后组合路径以形成正确的URI).
我不明白为什么URI ftp.contoso.com/file.ext.tmp适合上传而不是重命名?我在这里错过了什么吗?
该项目设置为.NET 4.0,在Visual Studio 2010中编码.
编辑
好的,我放置了代码片段.
请注意,应填写ftp主机,用户名和密码.要使此示例正常工作 - 即产生错误 - 用户目录必须与root不同("pwd" - 命令应返回与"/"不同的内容)
class Program
{
private const string fileName = "test.ext";
private const string tempFileName = fileName + ".tmp";
private const string ftpHost = "127.0.0.1"; …Run Code Online (Sandbox Code Playgroud) 我是powerbuilder的新手,在使用datawindows时遇到了很多麻烦.我无法理解它的插入机制.有人可以向我解释,或者至少指出我正确的方向(文章,提示等......)?
可能重复:
SQL服务器忽略where表达式中的大小写
基本上我需要检查这样的事情
select * from users where name = @name, pass = @pass
Run Code Online (Sandbox Code Playgroud)
问题是 'pass' = 'pAsS'
sql中是否存在更严格的字符串比较(ms sql-server)
我想要实现的是"动态"(即基于配置文件中定义的属性)启用/禁用子Spring XML上下文导入的能力.
我想象的是:
<import condition="some.property.name" resource="some-context.xml"/>
Run Code Online (Sandbox Code Playgroud)
解析属性的位置(布尔值)和true时导入上下文,否则不导入.
到目前为止我的一些研究:
编写自定义NamespaceHandler(和相关类),以便我可以在自己的命名空间中注册自己的自定义元素.例如:<myns:import condition="some.property.name" resource="some-context.xml"/>
这种方法的问题在于我不想从Spring复制整个资源导入逻辑,对我来说,我需要委派什么才能做到这一点.
DefaultBeanDefinitionDocumentReader以扩展"import"元素解析和解释的行为(在importBeanDefinitionResource方法中发生).但是我不确定我可以在哪里注册此扩展程序.在jQuery中,onchange如果textbox的值从其他事件动态变化,我如何跟踪事件.我尝试了这个,但它不起作用:
$("#txtbox").change(function(){
alert("change");
});
Run Code Online (Sandbox Code Playgroud) 我有这样的事情:
<form>
<input name='roles' type='checkbox' value='1' />
<input name='roles' type='checkbox' value='2' />
<input name='roles' type='checkbox' value='3' />
<input name='roles' type='checkbox' value='4' />
<input name='roles' type='checkbox' value='5' />
<input type='submit' value='submit' />
<form>
Run Code Online (Sandbox Code Playgroud)
我想验证是否应该检查至少一个复选框(角色),是否可以使用jquery.validate?
Chrome在加载时间期间或之后错误地报告图像的宽度和高度值.在此代码示例中使用了Jquery:
<img id='image01' alt='picture that is 145x134' src='/images/picture.jpg' />
<script>
var img = $( 'img#image01' )
img.width() // would return 145 in Firefox and 0 in Chrome.
img.height() // would return 134 in Firefox and 0 in Chrome.
</script>
Run Code Online (Sandbox Code Playgroud)
如果将脚本放在$(function(){})函数中,结果是相同的.但如果您在页面加载后几秒钟运行代码,则chrome会返回正确的结果.
<script>
function example () {
var img = $( 'img#image01' );
img.width() // returns 145 in both Firefox and Chrome.
img.height() // returns 134 in both Firefox and Chrome. …Run Code Online (Sandbox Code Playgroud) 我有以下xml文件.
<a>
<b>
<c>val1</c>
<d>val2</d>
</b>
<b>
<c>val3</c>
<d>val4</d>
</b>
<a>
Run Code Online (Sandbox Code Playgroud)
我想将它反序列化为一个类,我想用创建的类的对象访问它们.我正在使用C#.我能够反序列化并将值传递给类' a'(<a>标记)的对象.但是如何<b>从这个对象中获取值呢?我做了以下编码:
[Serializable()]
[XmlRoot("a")]
public class a
{
[XmlArray("a")]
[XmlArrayItem("b", typeof(b))]
public b[] bb{ get; set; }
}
[Serializable()]
public class b
{
[XmlElement("c")]
public string c{ get; set; }
[XmlElement("d")]
public string d{ get; set; }
}
class Program
{
static void Main(string[] args)
{
a i = null;
string path = "test.xml";
XmlSerializer serializer = new XmlSerializer(typeof(a));
StreamReader reader = new StreamReader(path); … 我正在使用GPU进行繁重的计算,这需要大量的渲染到纹理操作.这是一个迭代计算,因此对纹理进行大量渲染,然后将纹理渲染到另一个纹理,然后将第二个纹理渲染回第一个纹理,依此类推,每次都将纹理传递到着色器.
我的问题是:对于我想要渲染的每个纹理都有一个单独的FBO更好glFramebufferTexture2D吗,或者我应该在每次想要更改渲染目标时使用一个FBO并绑定目标纹理?
我的平台是iPhone上的OpenGL ES 2.0.
我有两个Web应用程序说App1和App2.我想从App1中的servlet调用App2中的servlet.我正在使用URLConnection.我也能够将参数传递给App2中的servlet,我也能够从servlet接收响应作为字符串.但我想从App2中的servlet发送java对象,并在App1的servlet中接收它们.怎么做到这一点?
jquery ×3
c# ×2
java ×2
javascript ×2
xml ×2
datawindow ×1
events ×1
framebuffer ×1
ftp ×1
html ×1
iphone ×1
opengl-es ×1
powerbuilder ×1
rename ×1
servlets ×1
spring ×1
sql ×1
sql-server ×1