要在使用文件之前查看文件是否存在,我们可以使用:
if (-e "filename.cgi")
{
#proceed with your code
}
Run Code Online (Sandbox Code Playgroud)
但是如何识别目录是否存在?
我可以使用下面的函数获得前三个字符.
但是,如何通过函数获得最后五个字符(三)的输出Substring().或者将使用其他字符串函数?
static void Main()
{
string input = "OneTwoThree";
// Get first three characters
string sub = input.Substring(0, 3);
Console.WriteLine("Substring: {0}", sub); // Output One.
}
Run Code Online (Sandbox Code Playgroud) 我是PHP的新手,我刚刚练习PHP setcookie()并且失败了.
http:// localhost/test/index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value);
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
http:// localhost/test/view.php
<?php
// I plan to view the cookie value via view.php
echo $_COOKIE["TestCookie"];
?>
Run Code Online (Sandbox Code Playgroud)
但我没能运行index.php,这样的IE警告.
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\index.php:9) in C:\xampp\htdocs\test\index.php on line 12
Run Code Online (Sandbox Code Playgroud)
毫无疑问,我启用了IE 6 cookie.
上面的程序有什么问题吗?谢谢.
使用WinXP OS和XAMPP 1.7.3.
我已经实现了在应用程序初始化时使用XmlTextWriter创建下面的XML文件.
并且知道我不知道如何使用XmlDocument和XmlNode更新childNode id值.
是否有一些属性来更新id值?我试过InnerText但是失败了.谢谢.
<?xml version="1.0" encoding="UTF-8"?>
<Equipment xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<License licenseId="" licensePath=""/>
<DataCollections>
<GroupAIDs>
<AID id="100">
<Variable id="200"/>
<Variable id="201"/>
</AID>
<AID id="">
<Variable id="205"/>
</AID>
<AID id="102"/>
</GroupAIDs>
<GroupBIDs>
<BID id="2000">
<AID id="100"/>
</BID>
<BID id="2001">
<AID id="101"/>
<AID id="102"/>
</BID>
</GroupBIDs>
<GroupCIDs>
<BID id="8"/>
<BID id="9"/>
<BID id="10"/>
</GroupCIDs>
</DataCollections>
</Equipment>
Run Code Online (Sandbox Code Playgroud) 我在winxp上使用XAMPP(PHP版本5.3.1).当我尝试在我的localhost上调用time()或date()函数时.它会显示警告信息,
严重性:警告
消息:date()[function.date]:依赖系统的时区设置是不安全的.您需要 使用date.timezone设置或date_default_timezone_set()函数.如果您使用了这些方法中的任何一种并且仍然收到此警告,则很可能拼错了时区标识符.我们选择'UTC'代替'8.0 /无DST'
文件名:helpers/date_helper.php
如何禁用警告?谢谢.
如果我宣布这样的字典:
private static Dictionary<string, object> aDict = new Dictionary<string, object>();
Run Code Online (Sandbox Code Playgroud)
现在我想在另一个地方使用它.我该如何重置?
aDict = new Dictionary<string, object>(); // like this?
aDict = null; // or like this?
Run Code Online (Sandbox Code Playgroud)
或其他重置样式?
我创建了两个RadioButton(重量和高度).我会在两个类别之间切换.但是它们共享相同的ListBox控制器(listBox1和listBox2).
有没有什么好方法可以更简单地清除所有ListBox项?我找不到ListBox的removeAll().我不喜欢我在这里发布的复杂的多行样式.
private void Weight_Click(object sender, RoutedEventArgs e)
{
// switch between the radioButton "Weith" and "Height"
// Clear all the items first
listBox1.Items.Remove("foot");
listBox1.Items.Remove("inch");
listBox1.Items.Remove("meter");
listBox2.Items.Remove("foot");
listBox2.Items.Remove("inch");
listBox2.Items.Remove("meter");
// Add source units items for listBox1
listBox1.Items.Add("kilogram");
listBox1.Items.Add("pound");
// Add target units items for listBox2
listBox2.Items.Add("kilogram");
listBox2.Items.Add("pound");
}
private void Height_Click(object sender, RoutedEventArgs e)
{
// switch between the radioButton "Weith" and "Height"
// Clear all the items first
listBox1.Items.Remove("kilogram");
listBox1.Items.Remove("pound");
listBox2.Items.Remove("kilogram");
listBox2.Items.Remove("pound");
// Add source units items for listBox1 …Run Code Online (Sandbox Code Playgroud) 当XML文件转换为ASCII时.这是用户在这三个人物不同的价值观utf和UTF.
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="UTF-8"?>
Run Code Online (Sandbox Code Playgroud)
我试图用vs2005创建一个新的xml文件.utf-8默认生成的表单文件.
哪一个是更标准的定义?谢谢.
string path = Path.GetDirectoryName(
Assembly.GetAssembly(typeof(MyClass)).CodeBase);
Run Code Online (Sandbox Code Playgroud)
输出:
文件:\ d:\学习\ CS \测试\的test.xml
返回d:\ learning\cs\test\test.xml的最佳方法是什么
file:\\doc.Save(returnPath)但是doc.Load(returnPath),当我打电话时会抛出异常; 效果很好.谢谢.