SendToPlugins/SendToSkydriveUI.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;
using System.Windows.Forms;
namespace SendToPlugins
{
public partial class SendToSkydriveUI : Form
{
private string _fileName;
public SendToSkydriveUI()
{
InitializeComponent();
}
public SendToSkydriveUI(string fileName)
: this()
{
_fileName = fileName;
}
private string ParseAndGetValue(string jsonText, string field)
{
var data = jsonText.Replace("\r\n", "").Replace("{", "").Replace("}", "").Replace("\"", "").Split(new[] { field }, StringSplitOptions.RemoveEmptyEntries);
return data[1].Trim();
}
private void cmdSignIn_Click(object sender, EventArgs e)
{
SkydriveAuth skyDriveAuth = new SkydriveAuth();
if (skyDriveAuth.ShowDialog() == DialogResult.OK)
{
string authCode = skyDriveAuth.AuthCode;
string url = string.Format(@"https://apis.live.net/v5.0/me/skydrive/files/{0}?access_token={1}", Path.GetFileName(_fileName), authCode);
using (var client = new WebClient())
{
client.UploadProgressChanged += ClientUploadProgressChanged;
client.UploadDataCompleted += ClientUploadDataCompleted;
client.UploadDataAsync(new Uri(url), "PUT", ImageToByteArray(_fileName));
}
}
}
private void ClientUploadDataCompleted(object sender, UploadDataCompletedEventArgs e)
{
if (e.Error != null)
{
throw new Exception("Unable to upload to sky drive", e.Error);
}
var jsonText = ASCIIEncoding.ASCII.GetString(e.Result);
string url = ParseAndGetValue(jsonText, "source:");
MessageBox.Show("File uploaded to Skydrive", "Send To Sky drive", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
}
void ClientUploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
后面还有 29 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
