[RunInstaller(true)]
public partial class Installer1 : Installer
{
public Installer1()
{
InitializeComponent();
}
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
}
private void Installer1_AfterInstall(object sender, InstallEventArgs e)
{
Form1 topmostForm = new Form1();
topmostForm.BringToFront();
topmostForm.TopMost = true;
topmostForm.ShowDialog();
} }
Run Code Online (Sandbox Code Playgroud)
我需要在默认的Windows Installer UI前面显示topmostForm.以上是我用于创建表单的CustomAction中的示例代码.设置TopMost属性或使用ShowDialog没有帮助.有没有其他解决方案可以让我的表格成为最重要的?
我想ENUM在c#中创建字符串.
基本上我不想设置表单名称Enum.当我在主页面打开表格的时候我想切换表格名称的情况并打开那个特定的表格.我知道ENUM只允许整数,但我想将其设置为string.任何的想法?
我想从某个网址下载 ZIP 文件。当我打开浏览器并写入URL时,浏览器直接开始下载ZIP文件。但是,我想要的是使用 C# 代码自动执行此操作。
我尝试了以下代码:
private void btnDownload_Click(object sender, EventArgs e) {
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadFileAsync(new Uri("http://---/file.zip"), @"c:\file.zip");
}
private void Completed(object sender, AsyncCompletedEventArgs e) {
MessageBox.Show("Download completed!");
}
Run Code Online (Sandbox Code Playgroud)
似乎下载正在运行,但是当我检查下载的文件时,我发现它为0 KB。
知道发生了什么吗?
在我的应用程序中,我正在使用 System.IO.FileStream (filePath) 读取 .PDF 文件。当文件夹具有本地用户权限时,此功能可以正常工作。当我从文件夹中删除本地用户权限时,这会出现访问被拒绝的错误。我正在使用这个代码...
System.IO.FileStream objFStream = new System.IO.FileStream(strPath, System.IO.FileMode.Open);
byte[] bytRead = new byte[(int)objFStream.Length];
objFStream.Read(bytRead, 0, (int)objFStream.Length);
objFStream.Close();
objFStream.Dispose();
Run Code Online (Sandbox Code Playgroud)
一旦我将 System.IO.FileStream 替换为 System.IO.File.OpenRead(strPath) ,它将起作用。替换代码是...
System.IO.FileStream objFStream = System.IO.File.OpenRead(strPath);
byte[] bytRead = new byte[(int)objFStream.Length];
objFStream.Read(bytRead, 0, (int)objFStream.Length);
objFStream.Close();
objFStream.Dispose();
Run Code Online (Sandbox Code Playgroud)
我想知道这有什么不同?如果有人知道请帮忙。
更新:当我执行单元测试项目然后它将返回未处理此测试结果还包含内部异常而不是 "Assert.IsTrue失败.描述字段是必需的." 结果如(0 Pass,1 FAIL,1 Total)但是如果我使用F11进行调试,我们根本没有得到任何异常
[TestMethod]
[Asynchronous]
[Description("Determines whether the selected or single property is valide using the validation context or validate single properties.")]
public void ValidateSigleWithDataAnnotation()
{
LookupsServices lookupsservices = new LookupsServices();
Lookups lookups = new Lookups() { Description = "", LookupReference = 2, DisplayOrder = 50};
lookupsservices.Lookups.Add(lookups);
//THIS IS NOT WORKING
string message = ValidateProperties.ValidateSingle(lookups, "Description");
Assert.IsTrue(message.Equals(""), message);
//THIS IS WORKING
var results = new List<ValidationResult>();
Validator.TryValidateProperty(lookups.Description , new ValidationContext(lookups, null, null) { MemberName …Run Code Online (Sandbox Code Playgroud) 我已经调用的存储过程usp_getTotalOrder,它看起来像
Select * from Order where CompanyID = 1;
Run Code Online (Sandbox Code Playgroud)
现在,我有一个包含存储过程名称的表.
在我的BLL中,我有一个存储过程名称.我想创建包含一个参数的函数,StoredProcedureName 并返回总行数
Declare @str varchar(50)
Set @str='GetOrders'; // Stored Procedure Name
Exec @str
Run Code Online (Sandbox Code Playgroud)
但它不返回我想从存储过程中获取的总行数,其名称在函数中.
任何的想法???请帮忙.....
c# ×5
.net ×2
enums ×1
installer ×1
sql ×1
sql-server ×1
url ×1
validation ×1
webclient ×1
winforms ×1