我有一个使用 ascii 编码用 C# 编写的文本文件,当我尝试使用 java 项目读取该文件时,我在文件开头得到一个ZERO WIDTH NO-BREAK SPACE字符。有人遇到过这种情况吗?
private static void SavePrivateKey(object key)
{
if (logger.IsInfoEnabled) logger.Info("SavePrivateKey - Begin");
string privatekey = (string)key;
string strDirName = Utility.RCTaskDirectory;
string strFileName = "PrivateKey.PPK";
string strKeyPathandName = Path.Combine(strDirName, strFileName);
//if (File.Exists(strKeyPathandName))
//{
// File.Create(strKeyPathandName);
//}
if (!string.IsNullOrEmpty(privatekey))
{//Save private key file
if (!Directory.Exists(strDirName))
Directory.CreateDirectory(strDirName);
FileStream fileStream = new FileStream(strKeyPathandName, FileMode.OpenOrCreate);
//TODO: Save File as ASCII
using (StreamWriter sw = new StreamWriter(fileStream, Encoding.ASCII))
{
if (logger.IsDebugEnabled) logger.DebugFormat("Saving the private key …
Run Code Online (Sandbox Code Playgroud) 我试图将我的代码编辑为以下但似乎不是正确的方法:
public int Compare(object x, object y)
{
string s1 = (string)x;
string s2 = (string)y;
return DateTime.Compare(DateTime.ParseExact(s1.Substring(1), "MMddyyyy", CultureInfo.InvariantCulture),
DateTime.ParseExact(s2.Substring(1), "MMddyyyy", CultureInfo.InvariantCulture));
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();
if (scheduleListBox.Items.Count == 0)
{
try
{
//Get all the directories name that start with "a"
fileNames = myStore.GetDirectoryNames("a*");
//Sort according to the schedule month
//Array.Sort(fileNames);
Array.Sort(new Compare(fileNames));
Run Code Online (Sandbox Code Playgroud)
我在数组列表中有a08102011格式的数据.
其中08是月, 10是日, 2011是年.
怎么能按照那种方式排序?
a08102011 …
实现ListPicker时,如果有足够的项目使其全屏显示,它将崩溃.如果只有2-3个项目并且它只是扩展,它不会崩溃.我得到一个ArgumentException,'参数不正确'
<toolkit:ListPicker Grid.Row="1"
ItemTemplate="{Binding lpkItemTemplate}"
FullModeItemTemplate="{Binding lpkFullItemTemplate}">
<toolkit:ListPicker.Items>
<toolkit:ListPickerItem>1</toolkit:ListPickerItem>
<toolkit:ListPickerItem>5</toolkit:ListPickerItem>
<toolkit:ListPickerItem>10</toolkit:ListPickerItem>
<toolkit:ListPickerItem>15</toolkit:ListPickerItem>
<toolkit:ListPickerItem>20</toolkit:ListPickerItem>
<toolkit:ListPickerItem>30</toolkit:ListPickerItem>
</toolkit:ListPicker.Items>
</toolkit:ListPicker>
Run Code Online (Sandbox Code Playgroud)
模板是
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Name="lpkItemTemplate">
<TextBlock Text="{Binding Content}" />
</DataTemplate>
<DataTemplate x:Name="lpkFullItemTemplate">
<TextBlock Text="{Binding Content}" />
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
Run Code Online (Sandbox Code Playgroud)
我看过一些例子,我没有看到任何与我在这里有什么不同的东西,而且它有效.唯一的区别是示例重做数据绑定.我已经尝试逐步调试控件的代码,但我没有看到任何弹出的内容.在ListPicker中完成'OnManipulationCompleted'事件处理程序之后,它会在基类'ItemsControl'中抛出异常.
我有什么想法吗?
我在c#上课
public class CompositeResource : Control
{
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public ResourceCollection Resources { get { return _resources; } }
}
public class Resource
{
[Bindable(true), DefaultValue(""), Editor("System.Web.UI.Design.UrlEditor, System.Design, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), Description("Specifies the URL of a resource to reference in the CompositeControl. The URL may be relative, root relative or absolute."), UrlProperty]
public String Url { get; set; }
[Bindable(true), DefaultValue(""), Description("Specifies the name of a resource to be used as a reference in the CompositeControl. The ReferenceName is typically used …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Windows Phone 7中的滑块.
但我不知道如何获得滑块停止点的值.
我想要这样的滑块最小值为1.
而最大值为10.
然后当滑块停止在一个点例子5. Den我将有一个文本块显示停止点的值.
我应该怎么做呢?我尝试了下面的代码,但仍然无法正常工作.
private void MinimumRangeSpan_TextChanged(object sender, TextChangedEventArgs e)
{
double value = 0;
double.TryParse(this.minimumRangeSpan.Text, out value);
this.rangeSlider.MinimumRangeSpan = value;
}
Run Code Online (Sandbox Code Playgroud)
我只需要一个简单的滑块,可以获得滑块的停止点.
我将xml文件从互联网下载到内存电话..我想查看是否可以通过互联网连接进行下载,如果没有则发送消息.如果不是,我想看看内存中是否已存在xml文件..如果存在,则应用程序不会进行下载.
问题是我不知道如何使"if"条件查看该文件是否存在.
我有这个代码:
public MainPage()
{
public MainPage()
{
if (NetworkInterface.GetIsNetworkAvailable())
{
InitializeComponent();
WebClient downloader = new WebClient();
Uri xmlUri = new Uri("http://dl.dropbox.com/u/32613258/file_xml.xml", UriKind.Absolute);
downloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Downloaded);
downloader.DownloadStringAsync(xmlUri);
}
else
{
MessageBox.Show("The internet connection is not available");
}
}
void Downloaded(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Result == null || e.Error != null)
{
MessageBox.Show("There was an error downloading the xml-file");
}
else
{
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
var stream = new IsolatedStorageFileStream("xml_file.xml", FileMode.Create, FileAccess.Write, myIsolatedStorage);
using (StreamWriter writeFile …
Run Code Online (Sandbox Code Playgroud) Windows 8和Windows Phone 8中是否有ADO.NET?我需要SqlConnection类.也许有额外的图书馆?
我是Powerbuilder的新手,我在运行时遇到了这个问题.当我运行我的程序时,它显示以下错误:
999 Cannot connect!
DBMS is not supported in your current installation
Run Code Online (Sandbox Code Playgroud)
这是什么原因?
我刚刚更新到Xcode 6并收到一条我无法解决的警告信息.我几个小时都在寻找答案,但没有运气.警告和代码行如下.有没有其他人有这个问题?
警告
从枚举类型'enum NSURLCacheStoragePolicy'到不同的枚举类型'NSURLRequestCachePolicy'(又名'enum NSURLRequestCachePolicy')的隐式转换
码
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:geocodeUrl] cachePolicy:NSURLCacheStorageAllowed timeoutInterval:10.0];
Run Code Online (Sandbox Code Playgroud)