Category Archives: .NET

Metodo Escrever em Arquivo Texto C#

Olá, Abaixo um método básico para escrever em arquivo texto em C# public void escreveArquivo(string dados) { string nome_arquivo = “C:/Temp/arquivo.txt”; if (!System.IO.File.Exists(nome_arquivo)) System.IO.File.Create(nome_arquivo).Close(); System.IO.TextWriter arquivo = System.IO.File.AppendText(nome_arquivo); arquivo.WriteLine(dados); arquivo.Close(); }

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> .NET | <span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> | Leave a comment

Alterar Texto SPAN com JQuery

Lê a página e altera o SPAN que tem title ‘Open Menu’ para ‘My Action 2′. Muito útil e rápido $(document).ready(function(){ $(“SPAN[title=’Open Menu’] A”).text(“My Actions 2”); });

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> .NET, SharePoint | <span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> , , | Leave a comment

C# Obter todos os usuários AD

Abaixo o código para obter todos os usuários do Active Directory (AD) do windows. Além de printar na tela ele insere em um arquivo texto. public void ObterUsuarioAD() { DirectoryEntry entry = new DirectoryEntry(“LDAP://SERVIDOR-AD”); DirectorySearcher dSearch = new DirectorySearcher(entry); dSearch.PageSize = 10000; dSearch.SizeLimit = 10000; dSearch.Filter = “(&(objectClass=user))”; // get all entries from the active […]

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> .NET | <span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> | Leave a comment

C# – Pegar todos usuarios cadastrado no AD

Em uma necessidade que tive de obter todos os usuários do AD, fiz algumas pesquisas no GOOGLE e encontrei uma boa referência e um código fácil de entender.   using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.DirectoryServices; using System.DirectoryServices.AccountManagement; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string groupName = […]

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> .NET | <span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> , | Leave a comment

C# – Criar e escrever em um arquivo txt

Vamos escolher onde criar o arquivo e qual nome daremos a ele. string nomeArquivo = “C:/Temp/Arquivo.txt”; Se o arquivo não existir criamos o arquivo com o seguinte comando abaixo: if (!System.IO.File.Exists(nomeArquivo)){ System.IO.File.Create(nomeArquivo).Close(); } Com a classe TextWriter escrevemos no arquivo. System.IO.TextWriter arquivo = System.IO.File.AppendText(nomeArquivo); arquivo.WriteLine(“Teste de escrita no arquivo”); Fechamos o arquivo: arquivo.Close(); Até a […]

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> .NET | <span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> , | Leave a comment

Criar tabs automaticamente utilizando o Ajax e adicionar controles

Para criar Tabs automaticamente utilizando o AjaxToolkit podemos trabalhar da seguinte forma: Adicione em sua página o controle ajax: <asp:TabContainer ID=”TabContainer1″ runat=”server” ActiveTabIndex=”0″> </asp:TabContainer> Observe que nenhuma Tab foi criada até o momento. Vamos então ao nosso behind e adicionar o seguinte código, a título de teste será adicionado no page_load. protected void Page_Load(object sender, […]

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> .NET | <span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> , | Leave a comment

Concatenar String Crystal Reports

Um post bem rápido de uma informação bem simples que as vezes esquecemos. Como concatenar string no Crystal Reports? Simples e prático. String-ou-variavel & string-ou-variavel Dessa maneira estaremos contatenando string contatenado = string1 & string2; resultado: string1string2; Como disse, simples e prático =]

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> .NET | Leave a comment

Como Verificar o tipo do objeto em C#

Este é um POST um tanto simples, mas não tão trivial para os programadores. Melhor dizendo e se você recebe um objeto o qual você não sabe o tipo? Ou se você estiver consumindo um serviço (WebService, WCF, etc…), mas e tiver em sua especificação que o tipo do objeto pode ser mudado? Pois bem, […]

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> .NET | <span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> , | Leave a comment

Classe para exportar GridView para Excel

Essa semana tive que exportar os dados de uma GridView para uma planilha Excel, bom… sabia que não era algo muito complicado, mas também nunca tinha feito, sendo assim realizei uma busca no grande mestre Google e encontrei uma classe que me atendeu muito bem. Fácil e descomplicado. using using System; using System.Data; using System.Configuration; using System.IO; […]

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> .NET | <span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> , | Leave a comment