snipt

Ctrl+h for KB shortcuts

C#

Get Embedded Resource

Stream fileStream= Assembly.GetExecutingAssembly().GetManifestResourceStream("NameSpace.FileNameWithExtension");
https://snipt.net/embed/c09658f584e5bcea0f623c463bbc3dc2/
/raw/c09658f584e5bcea0f623c463bbc3dc2/
c09658f584e5bcea0f623c463bbc3dc2
csharp
C#
1
2019-06-14T02:07:18
True
False
False
/api/public/snipt/41223/
get-embedded-resource
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="n">Stream</span> <span class="n">fileStream</span><span class="p">=</span> <span class="n">Assembly</span><span class="p">.</span><span class="n">GetExecutingAssembly</span><span class="p">().</span><span class="n">GetManifestResourceStream</span><span class="p">(</span><span class="s">&quot;NameSpace.FileNameWithExtension&quot;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
reflection

Text only

Using Reflection to load Microsoft.Web.Administration in PowerShell

1
2
3
4
[System.Reflection.Assembly]::LoadFrom("C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll")
$sm = new-object Microsoft.Web.Administration.ServerManager
$sm.Sites["test2"].Delete()
$sm.CommitChanges()
https://snipt.net/embed/9566fd81d55ab8acabc6f22f3728c31e/
/raw/9566fd81d55ab8acabc6f22f3728c31e/
9566fd81d55ab8acabc6f22f3728c31e
text
Text only
4
2019-06-20T13:38:05
True
False
False
/api/public/snipt/37601/
using-reflection-to-load-microsoftwebadministration-in-powershell
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>[System.Reflection.Assembly]::LoadFrom(&quot;C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll&quot;) </span><span id="L-2"><a name="L-2"></a>$sm = new-object Microsoft.Web.Administration.ServerManager </span><span id="L-3"><a name="L-3"></a>$sm.Sites[&quot;test2&quot;].Delete() </span><span id="L-4"><a name="L-4"></a>$sm.CommitChanges() </span></pre></div> </td></tr></table>
powershell, reflection