我想在文档的末尾添加一个分节符并添加一些文本.
我的代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
namespace WordDocManipulation
{
class Program
{
static void Main(string[] args)
{
string path = @"C:\sample.docx";
string strtxt = "Hello This is done by programmatically";
OpenAndAddTextToWordDocument(path,strtxt);
}
public static void OpenAndAddTextToWordDocument(string filepath, string txt)
{
/* I want to the below text to be added in the new section */
// Open a WordprocessingDocument for editing using the filepath.
WordprocessingDocument wordprocessingDocument =
WordprocessingDocument.Open(filepath, true);
// Assign a …Run Code Online (Sandbox Code Playgroud) 我想在我的代码中获取访问者的公共 IP 地址。
我写了下面的代码来获取它:
var context = System.Web.HttpContext.Current;
string ip = String.Empty;
if (context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
{
ip = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else if (!String.IsNullOrWhiteSpace(context.Request.UserHostAddress))
{
ip = context.Request.UserHostAddress;
}
if (ip == "::1")
ip = "127.0.0.1";
return ip;
Run Code Online (Sandbox Code Playgroud)
我没有得到确切的 IP 地址它返回的值如下:fe80::9419:dfb3:22ce:4e88%68但是当我在什么是我的 IP 中看到我的 IP 时?它显示13.67.58.30。我将如何获得确切的 IP 地址?
我是 Windows 桌面应用程序开发的新手。
我使用visual-studio 2010 创建了一个应用程序,其中我使用了一个表单进行数据输入。一种带有报表查看器控件和用于绘制报表的报表 (.rdlc) 文件的表单。
我的问题是我想让我的应用程序与 dot net framework 3.5 兼容。为此,我已将项目属性中的“高级编译选项...”中的目标框架更改为 3.5。但是在将目标框架更改为 3.5 后运行应用程序时出现错误是:
Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Line 123, position 5. C:\Users\Amir\Desktop\Bill_System\Bill_System\Bill_System\My Project\Resources.resx Billing_System
如何解决这个错误?
请帮忙。提前致谢。