【【C#】Win32 API 帮助类】教程文章相关的互联网学习教程文章

c# – 使用Google Drive API v3移动文件【代码】

我正在尝试使用Google Drive API v3将文件从一个文件夹移动到另一个文件夹.我找到了如何使用here的文档.我使用了文档页面中的.NET示例代码并创建了一个如下所示的方法:public ActionResult MoveFile(string fileToMove, string destination) {DriveService service = new DriveService(new BaseClientService.Initializer{HttpClientInitializer = <USER CREDENTIAL>,ApplicationName = "APPNAME"});var searchFiles = service.Fi...

如何将Daemon或Server的Azure AD OAuth2访问令牌和刷新令牌转换为C#ASP.NET Web API【代码】

我已经将Azure AD OAuth2守护程序或服务器实现为ASP.NET Web API.但是我只收到一个访问令牌,它是AuthenticationResult上的属性.见下面的实施.public IHttpActionResult GetAccessToken(string clientId, string clientkey){AuthenticationContext authContext = new AuthenticationContext(authority);ClientCredential clientCredential = new ClientCredential(clientId, clientkey);AuthenticationResult authenticationResult ...

c# – Bloomberg APIv3返回慢消费者警告

我基于API 3.2.9.0的SubscriptionWithEventHandlerExample示例在c#中创建了一个程序.订阅了大约500个实时数据证券后,我收到了一些声明SlowConsumerWarning和SlowConsumerWarningCleared的ADMIN事件警告.我在某个地方读到它引入了一些延迟,直到我处理所有事件. 问题是在我的代码中我只收到来自bloomberg的回调.事件队列甚至不在我的程序中! 我试过的一些事情: >提高队列限制,在会话选项中设置MaxEventQueueSize(似乎没有效果)>看看...

c# – .NET / Security:限制运行时加载的程序集访问某些API【代码】

在shell应用程序中,我需要能够在运行时加载和执行其他.NET程序集,但不能给予它们完全的信任.本质上,我想限制它们(加载的程序集)接触任何系统资源(线程,网络等),唯一的例外是隔离存储.但是,来自“我”的程序集需要以完全信任的方式执行. 我一直在考虑代码访问安全性,但我不太确定这是我应该使用的. 你会怎么做?解决方法:CAS几乎就是你需要的东西.更具体地说,您希望在自己的应用程序域中加载程序集:var myEvidence = new Evidence(...

c# – 如何在EWS MAPI中获取电子邮件的发件人?【代码】

我正在使用EWS托管API通过代码访问Exchange Server中的所有电子邮件.我遍历邮箱中的所有项目并加载它们: item.Load() 我需要知道项目/电子邮件的发件人.但我不知道如何访问有信息的属性.任何帮助表示赞赏.解决方法:这是我的解决方案:EmailMessage mes = (EmailMessage)item; TextBox1.Text = mes.Sender.Name;加载项目后,我只是将其转换为EmailMessage以访问属性和方法.

400错误请求使用C#YouTube API将视频上传到YouTube时出错【代码】

我似乎无法让我的ASP.net应用程序成功发布到我的YouTube帐户,但无论我做什么我得到400 Bad Request错误.我使用YouTube文档创建代码并获取开发密钥.此外,我没有收到和身份验证错误,所以我相信我的参数是正确的.尽管进行了大量的搜索,我仍然无法找到我的任务的确切答案,所以我只能假设我错误地使用了API或省略了一些关键的东西. 我的使用指令如下 使用系统;使用Google.GData.Client;使用Google.GData.YouTube;使用Google.GData.Exten...

c# – 通过.NET使用uTorrent Web API【代码】

我正在尝试使用Web API从uTorrent获取种子列表.获取所需的令牌是O.K.:WebClient client = new WebClient() { Credentials = new NetworkCredential(UserName, pass) }; StreamReader Reader = new StreamReader(client.OpenRead("http://localhost:" + port + "/gui/token.html")); string token = Reader.ReadToEnd(); token = token.Split('>')[2].Split('<')[0]; // token is now something like 3LemfrO_-A-SNBXlnQ2QcQWTYyd...

c# – Dropbox api“USER TOKEN”,“USER SECRET”【代码】

我正在尝试使用DropNet Client(Dropbox CLient API的C#版本)使用Dropbox Api操作文件.这是我的代码:var client = new DropNetClient(APP_KEY,APP_SECRET);client.Delete("/Public/test.txt");但似乎我也需要“用户忘记”和“用户秘密”.我应该在哪里获得这两个?更新:我只需要操纵我自己的文件夹和共享文件夹中的文件.我已经从myApp页面获得APP_KEY和APP_SECRET,在哪里可以获得“USER TOKEN”和“USER SECRET” 谢谢解决方法:当您...

c# – 返回任务的Web Api方法的缺点【代码】

为什么返回任务< T>的做法从Web Api方法而不是默认和在Visual Studio中创建新的Web Api控制器时获得的方法? 这样做有什么不利之处吗?public class MyController : ApiController {public Task<string> Boo(){return Task.Factory.StartNew(() =>{return "Boo";});} }解决方法:Are there any disadvantages to doing this?是的,你没有充分的理由让你的代码更不易读,更长,性能也更差.我没有看到这样做的任何好处.

c# – Angularjs和WebAPI Put方法参数始终为空【代码】

我有一个突然停止工作的应用程序.我无法确定为什么这是我知道它应该工作.我必须在这里找到一些非常简单的东西.这是代码,Angular代码调用API,API方法调用,但方法的参数始终为null.该呼叫是PUT呼叫.public static void Register(HttpConfiguration config) {// Web API configuration and services// Web API routesconfig.MapHttpAttributeRoutes();config.Routes.MapHttpRoute(name: "DefaultApi",routeTemplate: "api/{controller...

c# – 使用EF和WebApi将父/子对象序列化【代码】

我在实体框架中有以下模型:public class Customer { [XmlIgnore] public virtual ICollection<Customer> Children { get; set; }public string Name { get; set; } }现在我尝试使用web api序列化它:public class CustomerController:ApiController {public HttpResponseMessage GetAll(){using (var tc = new DataContext()){List<Customer> allCustomers = tc.Customers.ToList();return Request.CreateResponse(HttpStatusCode...

c# – 在SendGrid SMTP API中使用模板【代码】

我想知道,在C#中使用SendGrid模板的正确方法是什么?现在我得到以下错误:The error detected was: Templates error: ‘http_get returned non-20x response: ‘404 Not Found’ body={“error”: “active version not found”}’ 这是我的EmailService类,我想用它向用户发送电子邮件.如果我注释掉“EnableTemplateEngine”方法,一切似乎都有效,但我真的很想使用SendGrid模板.public class EmailService : IIdentityMessageServic...

c# – 在LocalFolder中存储BitmapImage – UWP【代码】

我正在尝试使用UWP上的C#将BitmapImage存储到文件系统.图像使用图形api从Facebook下载并作为BitmapImage返回.该部分工作,并检索图像(一旦我可以存储它,测试刚刚放在本地文件夹中的图片)我正在使用以下代码:public static async Task<BitmapImage> GetProfilePicture(string userId){BitmapImage profilePicture = new BitmapImage(); StorageFolder pictureFolder = awaitApplicationData.Current.LocalFolder.GetFolderAsync("Pr...

C#WebApi控制器(状态控制器目前有2个Get方法,1个返回List,第二个返回Single Item)【代码】

我的WebApiConfig:public static class WebApiConfig{public static void Register(HttpConfiguration config){// Web API configuration and services// Web API routesconfig.MapHttpAttributeRoutes();ODataModelBuilder builder = new ODataConventionModelBuilder();builder.EntitySet<Applicant>("Applicants");builder.EntitySet<Country>("Countries");builder.EntitySet<Program>("Programs");builder.EntitySet<Campus>...

c# – 在Diffusion中更新JSON主题(Unified .NET Client Api)【代码】

我正在尝试使用Diffusion的.NET客户端库更新JSON主题.我知道目前在.NET中只有部分支持JSON主题,但我认为可以更新主题.所以我使用Javascript客户端api创建了一个主题,然后使用C#进行更新.使用以下命令创建主题:var initvalue = diffusion.datatypes.json().from({ "name" : "some transaction example", "price": 2.00 });session.topics.add("examples/rmq/testtopic", initvalue);但在C#中更新它:updateControl.Updater.Update(...