下载带有Response.Write的文件时,文件名中的空格将替换为下划线,当关联的应用程序打开时,会附加方括号中的数字:
Response.AppendHeader("Content-disposition", "attachment; filename=this is the file.xml");
Response.Write(dr["InfopathDoc"]);
Run Code Online (Sandbox Code Playgroud)
这会在关联的应用程序中生成此文件名:
这个_is_ _文件[1] .xml
我如何摆脱下划线,为什么我得到[1]?
谢谢
我有一个XML文档,我需要从中提取节点集并添加命名空间.所以,从文档我提取这个:
<List>
<ListItem>
<SomeData>Here is some text</SomeText>
</ListItem>
<ListItem>
<SomeData>Here is some more text</SomeText>
</ListItem>
</List>
Run Code Online (Sandbox Code Playgroud)
并需要创建这个:
<my:List xmlsns:my='http://SomeNamespace.org>
<my:ListItem>
<my:SomeData>Here is some text</my:SomeText>
</my:ListItem>
<my:ListItem>
<SomeData>Here is some more text</my:SomeText>
</my:ListItem>
</my:List>
Run Code Online (Sandbox Code Playgroud)
将有可变数量的列表项,元素可能会更改并具有不同的名称,因此我需要一个通用的解决方案.在.Net C#中有一种简单的方法吗?
我想让扩展器标题中的一些文本左对齐,然后一些文本右对齐。我已经找到了如何将标题扩展到容器的宽度,并认为我可以简单地添加一个停靠面板并将第二个文本块设置为停靠右侧,但这似乎没有帮助。任何解决方案?
<Expander>
<Expander.Header>
<DockPanel
Width="{Binding
RelativeSource={RelativeSource
Mode=FindAncestor,
AncestorType={x:Type Expander}},
Path=ActualWidth}">
<TextBlock
Text="I am header text…"
Background="LightBlue"
/>
<TextBlock DockPanel.Dock="Right"
Text="I am header text…"
Background="Yellow"
/>
</DockPanel>
</Expander.Header>
</Expander>
Run Code Online (Sandbox Code Playgroud) 我在SQL Server表中有此XML:
<root>
<meetings>
<meeting>
<id>111</id>
<participants>
<participant><name>Smith</name></participant>
<participant><name>Jones</name></participant>
<participant><name>Brown</name></participant>
</participants>
</meeting>
<meeting>
<id>222</id>
<participants>
<participant><name>White</name></participant>
<participant><name>Bloggs</name></participant>
<participant><name>McDonald</name></participant>
</participants>
</meeting>
</meetings>
</root>
Run Code Online (Sandbox Code Playgroud)
并想要这样的结果集:
MeetingID Name
111 Smith
111 Jones
111 Brown
222 White
222 Bloggs
222 McDonald
Run Code Online (Sandbox Code Playgroud)
这很容易使用,select from openxml但是我无法使用XQuery。有人可以帮我在那儿,也许也可以对每种方法都有优缺点?
我的数据库中的某些文本字段嵌入了错误的控制字符.我在尝试序列化一个对象并在char 和.上获取xml错误时才注意到这一点.可能还有其他人.
如何使用C#替换它们?我认为这样的事情会起作用:
text.Replace('\x2', ' ');
Run Code Online (Sandbox Code Playgroud)
但事实并非如此.任何帮助赞赏.
我将 App.OnStartup 更改为异步,以便我可以在 Web api 上调用异步方法,但现在我的应用程序不显示其窗口。我在这里做错了什么:
protected override async void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
HttpResponseMessage response = await TestWebAPI();
if (!response.IsSuccessStatusCode)
{
MessageBox.Show("The service is currently unavailable");
Shutdown(1);
}
this.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
}
private async Task<HttpResponseMessage> TestWebAPI()
{
using (var webClient = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true }))
{
webClient.BaseAddress = new Uri(ConfigurationManager.AppSettings["WebApiAddress"]);
HttpResponseMessage response = await webClient.GetAsync("api/hello", HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
return response;
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我取出对 TestWebAPI 的异步调用,它会显示正常。