我正在将ticks值转换为这样的日期:
Convert(datetime, (MachineGroups.TimeAdded - 599266080000000000)/864000000000);
Run Code Online (Sandbox Code Playgroud)
使用这个我得到:
9/27/2009 10:50:27 PM
Run Code Online (Sandbox Code Playgroud)
但我想要这种格式的日期:
October 1, 2009
Run Code Online (Sandbox Code Playgroud)
我的样本滴答值是
633896886277130000
Run Code Online (Sandbox Code Playgroud)
做这个的最好方式是什么?
我有一个Web应用程序,它从bin文件夹导入DLL.
const string dllpath = "Utility.dll";
[DllImport(dllpath)]
Run Code Online (Sandbox Code Playgroud)
现在我想要做的是首先从不在当前项目中但在某个不同位置的文件夹中导入DLL.
该文件夹的路径存储在注册表项中.
我该怎么做?
编辑:
为什么我不能解决这个问题?
public partial class Reports1 : System.Web.UI.Page
{
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\xyz");
string pathName = (string)registryKey.GetValue("BinDir");
const string dllpath = pathName;
[DllImport(dllpath)]
public static extern bool GetErrorString(uint lookupCode, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder buf, uint bufSize);
protected void Page_Load(object sender, EventArgs e)
{
Run Code Online (Sandbox Code Playgroud)
string pathName = (string)registryKey.GetValue("BinDir");
是不是在这里工作,但正在页面加载事件...
但是,如果我这样做DLL导入将无法正常工作......我该如何解决这个问题?
好吧,我有一个字符串,我想删除由\分割的最后一个字
例如:
string name ="kak\kdk\dd\ddew\cxz\"
Run Code Online (Sandbox Code Playgroud)
现在我想删除最后一个单词,以便我获得名称的新值
name ="kak\kdk\dd\ddew \"
是否有捷径可寻
谢谢
我有一个需要UAC提升的应用程序.
我有代码,让我给出,但应用程序打开两次..这是问题..
所以这是Form1中的代码:
public Form1()
{
InitializeComponent();
WindowsPrincipal pricipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
bool hasAdministrativeRight = pricipal.IsInRole(WindowsBuiltInRole.Administrator);
if (!hasAdministrativeRight)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = true;
startInfo.WorkingDirectory = Environment.CurrentDirectory;
startInfo.FileName = Application.ExecutablePath;
startInfo.Verb = "runas";
try
{
Process p = Process.Start(startInfo);
}
catch (System.ComponentModel.Win32Exception ex)
{
return;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是代码programs.cs
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
Run Code Online (Sandbox Code Playgroud)
在调试时我发现它首先执行
进程p = Process.Start(startInfo);
这将打开应用程序UAC提升对话框,然后打开应用程序
但后来它去了
Application.Run(new Form1());
在main()中再次打开应用程序.
我不希望它再次打开应用程序...
我是新手,这是我做错了什么,我需要关闭UAC一旦打开..
谢谢
我有这个代码来创建一个本地Windows用户
public static bool CreateLocalWindowsAccount(string username, string password, string displayName, string description, bool canChangePwd, bool pwdExpires)
{
try
{
PrincipalContext context = new PrincipalContext(ContextType.Machine);
UserPrincipal user = new UserPrincipal(context);
user.SetPassword(password);
user.DisplayName = displayName;
user.Name = username;
user.Description = description;
user.UserCannotChangePassword = canChangePwd;
user.PasswordNeverExpires = pwdExpires;
user.Save();
//now add user to "Users" group so it displays in Control Panel
GroupPrincipal group = GroupPrincipal.FindByIdentity(context, "Users");
group.Members.Add(user);
group.Save();
return true;
}
catch (Exception ex)
{
LogMessageToFile("error msg" + ex.Message);
return false;
}
} …
Run Code Online (Sandbox Code Playgroud) 我使用log4net来记录错误.
目前我下载了该文件log4net.dll
,然后在global.asax
文件中进行了以下更改:
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected void Application_Start(object sender, EventArgs e)
{
log4net.Config.XmlConfigurator.Configure();
}
protected void Application_Error(object sender, EventArgs e)
{
Log.Fatal("An uncaught exception occurred", this.Server.GetLastError());
}
Run Code Online (Sandbox Code Playgroud)
这些更改也是在web.config文件中进行的
<log4net>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<param name="File" value="c:\Log4NetExample.log"/>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c %m%n"/>
</layout>
</appender>
<root>
<level value="All"/>
<appender-ref ref="LogFileAppender"/>
</root>
Run Code Online (Sandbox Code Playgroud)
一切正常..但我需要的是从代码移动代码web.config
并从文本文件中读取它.
另外我需要2级调试和错误..
谁能帮我这个?
谢谢
我正在尝试寻找一种简单的方法来设计一个带有组合框的winform,其中包含复选框值以选择多个值.但是我找不到免费样品.
如果任何人对不需要许可证的样本有良好的链接.请告诉我.
我不是在寻找像telerik和infragistics这样的控件.
我想用逗号和小数点显示一个数字
CASE1:示例,如果数字是3494309432324
显示为34,94,30,94,32,324但不是34,94,30,94,32,324.00
情况2:如果数字具有十进制值,则直到2个小数点并使用逗号
显示为12,22,222.32
目前我这样做2位小数,但我没有得到逗号
Label9.Text = sisRatio.ToString("#0.00");
有什么建议..
谢谢
现在这很棘手......我希望我能很好地解释它......
我有一个表,其中包含名称,我需要将它与我提供的单词进行比较,并得到完全匹配的结果。
现在我说这很棘手,因为我尝试了这个查询,它给了我一组名称。它包含完全匹配的单词以及相似的单词......
这就是我所做的:
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection();
connection.ConnectionString = ConfigurationManager.ConnectionStrings["xyz "].ConnectionString;
connection.Open();
SqlCommand sqlCmd = new SqlCommand("SELECT Names FROM Machines WHERE Name Like '%' + @userName + '%'", connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlCmd.Parameters.AddWithValue("@userName", userName);
sqlDa.Fill(dt);
connection.Close();
Run Code Online (Sandbox Code Playgroud)
现在我想要的是......例如。
如果数据库有三个单词
abc123
XYZ123
pqc1238
现在,如果单词是 123,则应返回 abc123 和 xyz123,如果 c123 则返回 abc123,而不是 pqc1238 和 xyz123
如果是 238 那么就返回 pqc1238....
我希望我说得足够清楚......相信我,我第一次也没明白
任何建议最好找到单词之间的精确匹配..因为 LIKE 是不够的..
谢谢
我在我的HTML中有这个,除了background-image之外一切都有效:'images/Header.jpg'; 相反,我看到标题中的灰色但不是图像..我尝试删除灰色但仍然没有看到图像...
#outerWrapper #header {
border-bottom: solid 1px #628152;
font-size: 18px;
font-weight: bold;
line-height: 15px;
height: 115px;
background-color: Grey;
background-image: url('images/Header.jpg');
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点..请帮忙..谢谢