Phone 7编程点滴
1. 修改文件名
1 public static void Move(string sourceFileName, string destFileName);
2.得到运行的EXE文件所在目录
1 /*函数功能: 获取程序所在路径 */ 2 public static string GetAppPath() 3 { 4 string usrdir; 5 usrdir = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase; 6 usrdir = System.IO.Path.GetDirectoryName(usrdir); 7 return usrdir; 8 } 9 // or: 10 Path.GetFullPath(Assembly.GetExecutingAssembly().GetName().CodeBase();
3. WP7数据存储方法
(1) 数据库、本地文件
(2) 全局域
(3) 将数据通过网络传送给服务端
(4) Isolate Storage
4. Windows Phone 7 使用GPS得到的坐标得到城市名( 应该是根据坐标获取附近的POI名称)?
转自:http://topic.csdn.net/u/20110415/21/3479235e-02dd-49bd-a476-205b213c66a8.html?60955
1 private void button1_Click(object sender, RoutedEventArgs e) 2 { 3 GeocodeServiceClient client = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); 4 5 client.ReverseGeocodeCompleted += new EventHandler<ReverseGeocodeCompletedEventArgs>(OnReverseGeocodeCompleted); 6 ReverseGeocodeRequest request = new ReverseGeocodeRequest(); 7 request.Credentials = new Credentials(); 8 request.Credentials.ApplicationId = "AjjGZGtCVs7lEuRn860kGigumg5hhJ8LqKXOIxpk1zwuxxQUgcrFDRWmrYfYCtFg"; 9 Location loc = new Location(); 10 loc.Latitude = 37.736025; 11 loc.Longitude = 115.66153; 12 request.Location = loc; 13 client.ReverseGeocodeAsync(request); 14 } 15 private void OnReverseGeocodeCompleted(object sender, ReverseGeocodeCompletedEventArgs e) 16 { 17 if (e.Error == null) 18 { 19 if (e.Result.Results.Count > 0) 20 { 21 GeocodeResponse response = e.Result; 22 this.textBlock1.Text = response.Results[0].DisplayName; 23 System.Collections.ObjectModel.ObservableCollection<GeocodeResult> list = response.Results; 24 string allName = ""; 25 foreach (GeocodeResult i in list) 26 { 27 allName += i.DisplayName + " "; 28 } 29 this.textBlock2.Text = allName; 30 } 31 else 32 MessageBox.Show("没有检索到该地理位置所对应的地点"); 33 } 34 }